Loading sjrpc/core/rpcconnection.py +16 −2 Original line number Diff line number Diff line Loading @@ -109,8 +109,7 @@ class RpcConnection(object): def receive(self): ''' Receive data from socket into the inbound buffer. If data can be decoded, do it and pass result to :meth:`dispatch` method. Receive data from socket into the inbound buffer. ''' try: Loading @@ -127,10 +126,22 @@ class RpcConnection(object): raise socket.error() self._inbound_buffer.push(buf) while self._process_inbound(): pass def _process_inbound(self): ''' Process the inbound buffer and :meth:`dispatch` messages. :return: False if nothing happened or True ''' # Read the message length: if self._cur_msg_size is None and len(self._inbound_buffer) >= 4: length = struct.unpack('!L', self._inbound_buffer.pull(4))[0] self._cur_msg_size = length return True # Read the message payload: if (self._cur_msg_size is not None Loading @@ -140,6 +151,9 @@ class RpcConnection(object): message = json.loads(payload) logging.debug('Received: %s' % message) self.dispatch(message) return True return False def _send(self, message): ''' Loading Loading
sjrpc/core/rpcconnection.py +16 −2 Original line number Diff line number Diff line Loading @@ -109,8 +109,7 @@ class RpcConnection(object): def receive(self): ''' Receive data from socket into the inbound buffer. If data can be decoded, do it and pass result to :meth:`dispatch` method. Receive data from socket into the inbound buffer. ''' try: Loading @@ -127,10 +126,22 @@ class RpcConnection(object): raise socket.error() self._inbound_buffer.push(buf) while self._process_inbound(): pass def _process_inbound(self): ''' Process the inbound buffer and :meth:`dispatch` messages. :return: False if nothing happened or True ''' # Read the message length: if self._cur_msg_size is None and len(self._inbound_buffer) >= 4: length = struct.unpack('!L', self._inbound_buffer.pull(4))[0] self._cur_msg_size = length return True # Read the message payload: if (self._cur_msg_size is not None Loading @@ -140,6 +151,9 @@ class RpcConnection(object): message = json.loads(payload) logging.debug('Received: %s' % message) self.dispatch(message) return True return False def _send(self, message): ''' Loading