Piotr Kliczewski has uploaded a new change for review.

Change subject: stomp: preparation of subscribtion class for subscription 
management
......................................................................

stomp: preparation of subscribtion class for subscription management


Change-Id: I40cb609432c3d5a7d297e25647a152abdc8e86c5
Signed-off-by: pkliczewski <[email protected]>
---
M lib/yajsonrpc/stomp.py
1 file changed, 25 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/68/41068/1

diff --git a/lib/yajsonrpc/stomp.py b/lib/yajsonrpc/stomp.py
index 86cbf6d..25e11e2 100644
--- a/lib/yajsonrpc/stomp.py
+++ b/lib/yajsonrpc/stomp.py
@@ -480,28 +480,39 @@
 
 
 class _Subscription(object):
-    def __init__(self, client, subid, ack):
+
+    def __init__(self, client, destination, subid, ack, message_handler):
         self._ack = ack
         self._subid = subid
         self._client = client
         self._valid = True
+        self._message_handler = message_handler
+        self._destination = destination
+
+    def handle_message(self, frame):
+        self._message_handler(self, frame)
+
+    """
+    In order to process message we need to set message
+    handler which is responsible for processing jsonrpc
+    content of the message. Currently there are 2 handlers:
+    JsonRpcClient and JsonRpcServer.
+    """
+    def set_message_handler(self, handler):
+        self._message_handler = handler
 
     @property
     def id(self):
         return self._subid
 
+    @property
+    def destination(self):
+        return self._destination
+
+    @property
+    def client(self):
+        return self._client
+
     def unsubscribe(self):
-        client = self._client
-        subid = self._subid
-
-        client._unregisterSubscription(self)
-
-        frame = Frame(Command.UNSUBSCRIBE,
-                      {"id": str(subid)})
-        client.put(frame)
+        self._client.unsubscribe(self)
         self._valid = False
-
-    def __del__(self):
-        # Using a timer because unsubscribe action might involve taking locks.
-        if self._valid:
-            Timer(0, self.unsubscribe)


-- 
To view, visit https://gerrit.ovirt.org/41068
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I40cb609432c3d5a7d297e25647a152abdc8e86c5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Piotr Kliczewski <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to