finished handle_incoming

This commit is contained in:
Alex Haynes
2018-11-11 17:55:50 -05:00
parent e44e31e55b
commit cacbc6c11a
2 changed files with 9 additions and 2 deletions

View File

@ -83,7 +83,15 @@ class MuxedConn(IMuxedConn):
if not chunk: if not chunk:
break break
data += chunk 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 header
# Read message length # Read message length
# Read message into corresponding buffer # Read message into corresponding buffer

View File

@ -11,10 +11,9 @@ def encode_uvarint(number):
break break
return buf return buf
def decode_uvarint(buff): def decode_uvarint(buff, index):
shift = 0 shift = 0
result = 0 result = 0
index = 0
while True: while True:
i = buff[index] i = buff[index]
result |= (i & 0x7f) << shift result |= (i & 0x7f) << shift