Revision efc6b445 ncclient/listener.py
b/ncclient/listener.py | ||
---|---|---|
18 | 18 |
|
19 | 19 |
def __init__(self): |
20 | 20 |
self._id2rpc = {} |
21 |
self._subscription_id = None # notifications are delivered to the rpc |
|
22 |
# that created the subscription |
|
21 |
self._sub_id = None # message-id of <create-subscription> request |
|
23 | 22 |
|
24 | 23 |
def set_subscription(self, id): |
25 | 24 |
self._subscription = id |
26 | 25 |
|
26 |
def register(self, id, op): |
|
27 |
self._id2rpc[id] = op |
|
28 |
|
|
29 |
def unregister(self, id): |
|
30 |
del self._id2prc[id] |
|
31 |
|
|
32 |
### Events |
|
33 |
|
|
27 | 34 |
def reply(self, raw): |
28 |
id, is_notification = rpc.parse(raw) |
|
29 |
if is_notification: |
|
30 |
self._id2rpc[self._subscription_id].event(raw) |
|
31 |
else: |
|
35 |
id = rpc.parse(raw) |
|
36 |
if id: |
|
32 | 37 |
self._id2rpc[id]._deliver(raw) |
33 |
del self._id2rpc[id] |
|
38 |
else: |
|
39 |
self._id2rpc[self._sub_id]._notify(raw) |
|
34 | 40 |
|
35 |
def error(self, buf): |
|
36 |
pass |
|
41 |
def close(self, buf): |
|
42 |
pass # TODO |
Also available in: Unified diff