diff --git a/muxer/mplex/muxed_connection.py b/muxer/mplex/muxed_connection.py index 98b4d54..e6d5819 100644 --- a/muxer/mplex/muxed_connection.py +++ b/muxer/mplex/muxed_connection.py @@ -83,7 +83,15 @@ class MuxedConn(IMuxedConn): if not chunk: break data += chunk + header, end_index = decode_uvarint(data, 0) + length, end_index = decode_uvarint(data, end_index) + message = data[end_index, end_index + length] + # Deal with other types of messages + flag = header & 0x07 + stream_id = header >> 3 + + self.buffers[stream_id] = self.buffers[stream_id] + message # Read header # Read message length # Read message into corresponding buffer diff --git a/muxer/mplex/utils.py b/muxer/mplex/utils.py index c4696f8..4e20241 100644 --- a/muxer/mplex/utils.py +++ b/muxer/mplex/utils.py @@ -11,10 +11,9 @@ def encode_uvarint(number): break return buf -def decode_uvarint(buff): +def decode_uvarint(buff, index): shift = 0 result = 0 - index = 0 while True: i = buff[index] result |= (i & 0x7f) << shift