Home | Trees | Indices | Help |
---|
|
Python objects can register callbacks with the bus and be called when elisa.core.bus.bus_message.Messages are sent by other objects.
Here is a simple example:bus = Bus() def my_cb(message, sender): print 'Got message %r from %r' % (message, sender) bus.register(my_cb) bus.send_message(Message())Messages dispatching empties the message queue and call the registered callbacks. Messages filtering is also supported, just pass a Message type class to bus.register(), like this:
bus.register(my_cb, Message)You can filter on multiple Message types by supplying a list to bus.register():
bus.register(my_cb, (FooMessage, DataMessage))
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from Inherited from |
|
|||
Inherited from |
|
|||
dict, keys are callable objects and values are Message types lists |
callbacks registered callbacks |
|
|||
Inherited from |
|
|
Start message dispatching: once started, messages sent over the bus are guaranteed to be dispatched. Queued messages are dispatched inside a separate thread. |
Send a message over the bus. The message is automatically dispatched (inside a thread) if the Bus is running. Otherwise the message is locally queued until the Bus starts. MT safe.
|
Register a new callback with the bus. The given callback will be called when a message of one of the given types is dispatched on the bus. MT safe.
|
Unregister a callback from the bus. MT safe.
|
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0beta1 on Wed Jan 16 19:08:41 2008 | http://epydoc.sourceforge.net |