当前位置: 首页>>代码示例>>Python>>正文


Python EventBus.register_handler方法代码示例

本文整理汇总了Python中core.event_bus.EventBus.register_handler方法的典型用法代码示例。如果您正苦于以下问题:Python EventBus.register_handler方法的具体用法?Python EventBus.register_handler怎么用?Python EventBus.register_handler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core.event_bus.EventBus的用法示例。


在下文中一共展示了EventBus.register_handler方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: register_method

# 需要导入模块: from core.event_bus import EventBus [as 别名]
# 或者: from core.event_bus.EventBus import register_handler [as 别名]
def register_method(message):
	address = message.body.get("address", None)
	method = message.body.get("method", None)
	module = message.body.get("module", None)
	if (address != None and method != None and module != None):
		EventBus.register_handler(address, "%s.%s"% (module,method))
	else: 
		message.reply("register_method missing address or method or module")
开发者ID:jakubjosef,项目名称:Vert.x-File-Hosting,代码行数:10,代码来源:services.py

示例2: login_handler

# 需要导入模块: from core.event_bus import EventBus [as 别名]
# 或者: from core.event_bus.EventBus import register_handler [as 别名]
def login_handler(msg):
    user = msg.body
    id = vertx.config()['user-prefix'] + str(uuid.uuid4())
    users.add(user)
    EventBus.register_handler(id, 
                              handler=lambda msg: command_handler(user, msg))
    EventBus.publish(vertx.config()['users-address'], user)
    msg.reply({'id': id, 'users': list(users)})
开发者ID:tobias,项目名称:vertx-codemash-2014,代码行数:10,代码来源:routing.py

示例3: start

# 需要导入模块: from core.event_bus import EventBus [as 别名]
# 或者: from core.event_bus.EventBus import register_handler [as 别名]
    def start(self):
        #self.eventBus.registerHandler(self.address, self);
        self.config = VertxLocator.container.getConfig()
        self.engine = create_engine(self.db_path, echo=False)

        self.Session = sessionmaker(bind=self.engine)

        EventBus.register_handler(self.address, handler=self.handle)

        self.metadata.create_all(self.engine)
开发者ID:parroit,项目名称:mod-alchemy-persistor,代码行数:12,代码来源:AlchemyPersistor.py

示例4: register

# 需要导入模块: from core.event_bus import EventBus [as 别名]
# 或者: from core.event_bus.EventBus import register_handler [as 别名]
    def register(self):
        def handler(msg):
            if not msg.body.has_key('error'):
                headers = { 'Authorization': 'token '+msg.body['access_token'] }
                get('https://api.github.com/user', handle_response, headers=headers)
                if 'email' in msg.body['scope']: pass
            else:
                logger.error(msg.body)

        EventBus.register_handler('auth.github.login', handler=handler)
开发者ID:stt,项目名称:vertx-trans,代码行数:12,代码来源:github.py

示例5: test_deploy

# 需要导入模块: from core.event_bus import EventBus [as 别名]
# 或者: from core.event_bus.EventBus import register_handler [as 别名]
    def test_deploy(self):

        def handler(message):
            if message.body == "started":
                tu.test_complete()
        EventBus.register_handler("test-handler", False, handler)
        conf = {'foo' : 'bar'}
        def deploy_handler(err, ok):
            tu.azzert(err == None)

        vertx.deploy_verticle("core/deploy/child.py", conf, 1, deploy_handler)
开发者ID:fregaham,项目名称:mod-lang-jython,代码行数:13,代码来源:test_client.py

示例6: test_deploy

# 需要导入模块: from core.event_bus import EventBus [as 别名]
# 或者: from core.event_bus.EventBus import register_handler [as 别名]
 def test_deploy(self):
     global handler_id
     def handler(message):
         if message.body == "started":
             tu.test_complete()
     handler_id = EventBus.register_handler("test-handler", False, handler)
     conf = {'foo' : 'bar'}
     vertx.deploy_verticle("core/deploy/child.py", conf)
开发者ID:emangchi,项目名称:vert.x,代码行数:10,代码来源:test_client.py

示例7: get_auth_uid

# 需要导入模块: from core.event_bus import EventBus [as 别名]
# 或者: from core.event_bus.EventBus import register_handler [as 别名]
 def get_auth_uid(uid):
     if (uid.body == None): message.reply(None)
     else:
         userID = uid.body
         get_user_eb = EventBus.register_handler("get_user_private", handler = get_user)
         def user_handler(user):
             message.reply(user.body)
             EventBus.unregister_handler(get_user_eb)
         EventBus.send("get_user_private", {"userID":userID}, user_handler)
开发者ID:jakubjosef,项目名称:Vert.x-File-Hosting,代码行数:11,代码来源:bus_utils.py

示例8: test_undeploy

# 需要导入模块: from core.event_bus import EventBus [as 别名]
# 或者: from core.event_bus.EventBus import register_handler [as 别名]
    def test_undeploy(self):
        print "in test undeploy"
        def handler(message):
            return

        EventBus.register_handler("test-handler", False, handler)

        conf = {'foo' : 'bar'}

        def undeploy_handler(err):
            tu.azzert(err == None)
            tu.test_complete()

        def deploy_handler(err, id):
            tu.azzert(err == None)
            vertx.undeploy_verticle(id, handler=undeploy_handler)

        vertx.deploy_verticle("core/deploy/child.py", conf, handler=deploy_handler)
开发者ID:fregaham,项目名称:mod-lang-jython,代码行数:20,代码来源:test_client.py

示例9: test_send_empty

# 需要导入模块: from core.event_bus import EventBus [as 别名]
# 或者: from core.event_bus.EventBus import register_handler [as 别名]
 def test_send_empty(self):
     json = {}
     address = "some-address"
     def handler(msg):
         tu.azzert(msg.body == {})
         EventBus.unregister_handler(id)
         tu.test_complete()
     id = EventBus.register_handler(address, handler=handler)
     tu.azzert(id != None)
     EventBus.send(address, json)
开发者ID:johnkewforks,项目名称:mod-lang-jython,代码行数:12,代码来源:test_client.py

示例10: test_simple_send

# 需要导入模块: from core.event_bus import EventBus [as 别名]
# 或者: from core.event_bus.EventBus import register_handler [as 别名]
    def test_simple_send(self):
        json = {'message' : 'hello world!'}
        address = "some-address"

        def handler(msg):
            tu.azzert(msg.body['message'] == json['message'])
            EventBus.unregister_handler(id)
            tu.test_complete()
        id = EventBus.register_handler(address, handler=handler)
        tu.azzert(id != None)
        EventBus.send(address, json)
开发者ID:johnkewforks,项目名称:mod-lang-jython,代码行数:13,代码来源:test_client.py

示例11: __init__

# 需要导入模块: from core.event_bus import EventBus [as 别名]
# 或者: from core.event_bus.EventBus import register_handler [as 别名]
 def __init__(self, cfg, creds):
     self.id = cfg['id']
     self.cfg = cfg
     self.client = self._build_client(cfg, creds)
     self.address = "hbdriver:client:" + self.id
     self._handlers = []
     for addr, h in [(self.address, self.handler),
                     (self.STATUS_ADDRESS, self.status_handler),
                     (self.SHUTDOWN_ADDRESS, self.shutdown_handler)]:
         hid = EventBus.register_handler(addr, handler=h)
         self._handlers.append(hid)
开发者ID:ninowalker,项目名称:hosebird-driver-mod,代码行数:13,代码来源:hbdriver.py

示例12: test_reply_timeout

# 需要导入模块: from core.event_bus import EventBus [as 别名]
# 或者: from core.event_bus.EventBus import register_handler [as 别名]
    def test_reply_timeout(self):
        json = {'message': 'hello world!'}
        address = 'some-address'
        reply = {'cheese': 'stilton!'}
        def handler(msg):
            tu.azzert(msg.body['message'] == json['message'])
        id = EventBus.register_handler(address, handler=handler)
        tu.azzert(id != None)

        def reply_handler(error, msg):
            tu.azzert(error != None)
            EventBus.unregister_handler(id)
            tu.test_complete()
        EventBus.send_with_timeout(address, json, 10, reply_handler)
开发者ID:johnkewforks,项目名称:mod-lang-jython,代码行数:16,代码来源:test_client.py

示例13: test_reply

# 需要导入模块: from core.event_bus import EventBus [as 别名]
# 或者: from core.event_bus.EventBus import register_handler [as 别名]
    def test_reply(self):
        json = {'message' : 'hello world!'}
        address = "some-address"
        reply = {'cheese' : 'stilton!'}
        def handler(msg):
            tu.azzert(msg.body['message'] == json['message'])
            msg.reply(reply)    
        id = EventBus.register_handler(address, handler=handler)
        tu.azzert(id != None)

        def reply_handler(msg):
            tu.azzert(msg.body['cheese'] == reply['cheese'])
            EventBus.unregister_handler(id)
            tu.test_complete()    
        EventBus.send(address, json, reply_handler)
开发者ID:johnkewforks,项目名称:mod-lang-jython,代码行数:17,代码来源:test_client.py

示例14: echo

# 需要导入模块: from core.event_bus import EventBus [as 别名]
# 或者: from core.event_bus.EventBus import register_handler [as 别名]
 def echo(self, msg):
     address = "some-address"
     class Handler(object):
         def handler_func(self, received):
             tu.check_thread()
             EventBus.unregister_handler(self.id)
             received.reply(received.body)
     handler = Handler()
     handler.id = EventBus.register_handler(address, handler=handler.handler_func)
     
     def reply_handler(reply):
         if isinstance(reply.body, dict):
             for k,v in reply.body.iteritems():
                 tu.azzert(msg[k] == v)
         else:
             tu.azzert(msg == reply.body)
         tu.test_complete()
     EventBus.send(address, msg, reply_handler)
开发者ID:johnkewforks,项目名称:mod-lang-jython,代码行数:20,代码来源:test_client.py

示例15: test_send_multiple_matching_handlers

# 需要导入模块: from core.event_bus import EventBus [as 别名]
# 或者: from core.event_bus.EventBus import register_handler [as 别名]
    def test_send_multiple_matching_handlers(self):
        json = {'message' : 'hello world!'}
        address = "some-address"
        num_handlers = 10
        count = [0] # use an array to ensure pass by ref

        for i in range(0,num_handlers):
            class Handler(object):
                def __init__(self, count):
                    self.count = count
                def handler_func(self, msg):
                    tu.azzert(msg.body['message'] == json['message'])
                    EventBus.unregister_handler(self.id)
                    self.count[0] += 1
                    if self.count[0] == num_handlers:
                        tu.test_complete()
            handler = Handler(count)
            handler.id = EventBus.register_handler(address, handler=handler.handler_func)
        EventBus.publish(address, json)
开发者ID:johnkewforks,项目名称:mod-lang-jython,代码行数:21,代码来源:test_client.py


注:本文中的core.event_bus.EventBus.register_handler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。