summaryrefslogtreecommitdiff
path: root/src/leap/common/events/server.py
diff options
context:
space:
mode:
authorTomas Touceda <chiiph@riseup.net>2013-06-19 14:31:49 -0300
committerTomas Touceda <chiiph@riseup.net>2013-06-19 14:31:49 -0300
commitc84521f7881dc7b4197f57300bfe0511aa47dac2 (patch)
tree0ec1938b79b527ed94e9d54a21122ce88c0dab39 /src/leap/common/events/server.py
parentdbbf33d27268266088ee1ab15fc04cef33259250 (diff)
parenta08b198d889396d25182bb9716817311bcc3be47 (diff)
Merge remote-tracking branch 'drebs/feature/2696-implement-unregister-in-events-2' into develop
Diffstat (limited to 'src/leap/common/events/server.py')
-rw-r--r--src/leap/common/events/server.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/leap/common/events/server.py b/src/leap/common/events/server.py
index 1f3a874..d53c218 100644
--- a/src/leap/common/events/server.py
+++ b/src/leap/common/events/server.py
@@ -100,6 +100,33 @@ class EventsServerService(proto.EventsServerService):
response.status = proto.EventResponse.OK
done.run(response)
+ def unregister(self, controller, request, done):
+ """
+ Unregister a component port so it will not be signaled when specific
+ events come in.
+
+ :param controller: used to mediate a single method call
+ :type controller: protobuf.socketrpc.controller.SocketRpcController
+ :param request: the request received from the component
+ :type request: leap.common.events.events_pb2.RegisterRequest
+ :param done: callback to be called when done
+ :type done: protobuf.socketrpc.server.Callback
+ """
+ logger.info(
+ "Received unregistration request: %s..." % str(request)[:40])
+ # remove component port from signal list
+ response = proto.EventResponse()
+ if request.event in registered_components:
+ try:
+ registered_components[request.event].remove(request.port)
+ response.status = proto.EventResponse.OK
+ except KeyError:
+ response.status = proto.EventsResponse.ERROR
+ response.result = 'Port %d not registered.' % request.port
+ # send response back to component
+ logger.debug('sending response back')
+ done.run(response)
+
def signal(self, controller, request, done):
"""
Perform an RPC call to signal all components registered to receive a