Esempio n. 1
0
'''
Created on 2013-4-6

@author: kfirst
'''

from flex.core import core
import time
from flex.base.handler import StorageHandler

class testListen(StorageHandler):

    def handle_storage(self, key, value, domain, type):
        print key, value, domain, type


core.set_config_path('config')
core.start()
logger = core.get_logger()
logger.warning('test')
core.myself.get_self_controller()
print core.globalStorage.set('bbbbbbbbb', 12323)
time.sleep(1)
print core.globalStorage.get('bbbbbbbbb')
core.globalStorage.listen_domain(testListen(), 'default', listen_myself = True)
core.globalStorage.sadd_multi('bb', ([1, 2], 'a'))
time.sleep(1)
Esempio n. 2
0
'''
Created on 2013-4-8

@author: kfirst
'''

from flex.core import core

core.set_config_path('../config')
core.start()
selector = core.selector

values = set([1, 2, 3, 4, 5])
print selector.select(values)
print selector.select(values)
Esempio n. 3
0
"""
Created on 2013-4-17

@author: kfirst
"""

from flex.core import core
import time
from flex.base.handler import DataHandler


class Handler(DataHandler):
    def handle(self, data):
        print "receive data " + str(data)


core.set_config_path("../config")
core.start()
network = core.network
network.register_data_handler(Handler())

network.send(("127.0.0.1", 12210), "test1")
network.send(("127.0.0.1", 12210), "test2")

time.sleep(1)

network.send(("127.0.0.1", 12210), "test3")
network.send(("127.0.0.1", 12210), "test4")

time.sleep(1)