From a982a0de2b290beecf907a2210b43faef1bb70c0 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Wed, 10 Apr 2013 20:03:15 +0900 Subject: add RAISE_WINDOW event --- src/leap/common/events/README.rst | 53 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/leap/common/events/README.rst (limited to 'src/leap/common/events/README.rst') diff --git a/src/leap/common/events/README.rst b/src/leap/common/events/README.rst new file mode 100644 index 0000000..813be8b --- /dev/null +++ b/src/leap/common/events/README.rst @@ -0,0 +1,53 @@ +Events mechanism +================ + +The events mechanism allows for "components" to send signal events to each +other by means of a centralized server. Components can register with the +server to receive signals of certain types, and they can also send signals to +the server that will then redistribute these signals to registered components. + + +Listening daemons +----------------- + +Both components and the server listen for incoming messages by using a +listening daemon that runs in its own thread. The server daemon has to be +started explicitly, while components daemon will be started whenever a +component registers with the server to receive messages. + + +How to use it +------------- + +To start the events server: + +>>> from leap.common.events import server +>>> server.ensure_server(port=8090) + +To register a callback to be called when a given signal is raised: + +>>> from leap.common.events import ( +>>> register, +>>> events_pb2 as proto, +>>> ) +>>> +>>> def mycallback(sigreq): +>>> print str(sigreq) +>>> +>>> events.register(signal=proto.CLIENT_UID, callback=mycallback) + +To signal an event: + +>>> from leap.common.events import ( +>>> signal, +>>> events_pb2 as proto, +>>> ) +>>> signal(proto.CLIENT_UID) + +Adding events +------------- + +* Add the new event under enum ``Event`` in ``events.proto`` +* Compile the new protocolbuffers file:: + + make -- cgit v1.2.3