From 02f50239fc1ddf2cbb31988a6ba4588aceef7983 Mon Sep 17 00:00:00 2001 From: Pedro Ferreira Date: Sun, 30 Jul 2017 10:52:04 +0200 Subject: [PATCH] Apparently working sink handler --- ssb/api.py | 4 ++-- test_client.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ssb/api.py b/ssb/api.py index cd51929..605609d 100644 --- a/ssb/api.py +++ b/ssb/api.py @@ -22,8 +22,8 @@ class MuxRPCSourceHandler(object): class MuxRPCSinkHandlerMixin(object): - def send(self, msg, msg_type=PSMessageType.JSON): - self.connection.send(msg, stream=True, msg_type=msg_type, req=self.req) + def send(self, msg, msg_type=PSMessageType.JSON, end=False): + self.connection.send(msg, stream=True, msg_type=msg_type, req=self.req, end_err=end) class MuxRPCDuplexHandler(MuxRPCSinkHandlerMixin, MuxRPCSourceHandler): diff --git a/test_client.py b/test_client.py index 2cb1744..1b6f8b0 100644 --- a/test_client.py +++ b/test_client.py @@ -47,7 +47,12 @@ async def main(): handler.send(struct.pack('l', int(time.time() * 1000)), msg_type=PSMessageType.BUFFER) async for msg in handler: print('> RESPONSE:', msg) + handler.send(True, end=True) + break + handler = api.call('blobs.add', [], 'sink') + handler.send(b'dead0beef', msg_type=PSMessageType.BUFFER) + handler.send(True, end=True) # create console handler and set level to debug ch = logging.StreamHandler()