Websocket update.
This commit is contained in:
parent
41e12d304e
commit
851d1de1be
@ -87,8 +87,7 @@ class AOProtocol(asyncio.Protocol):
|
|||||||
self.client.disconnect()
|
self.client.disconnect()
|
||||||
for msg in self.get_messages():
|
for msg in self.get_messages():
|
||||||
if len(msg) < 2:
|
if len(msg) < 2:
|
||||||
self.client.disconnect()
|
continue
|
||||||
return
|
|
||||||
# general netcode structure is not great
|
# general netcode structure is not great
|
||||||
if msg[0] in ('#', '3', '4'):
|
if msg[0] in ('#', '3', '4'):
|
||||||
if msg[0] == '#':
|
if msg[0] == '#':
|
||||||
@ -100,7 +99,7 @@ class AOProtocol(asyncio.Protocol):
|
|||||||
cmd, *args = msg.split('#')
|
cmd, *args = msg.split('#')
|
||||||
self.net_cmd_dispatcher[cmd](self, args)
|
self.net_cmd_dispatcher[cmd](self, args)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return
|
logger.log_debug('[INC][UNK]{}'.format(msg), self.client)
|
||||||
|
|
||||||
def connection_made(self, transport):
|
def connection_made(self, transport):
|
||||||
""" Called upon a new client connecting
|
""" Called upon a new client connecting
|
||||||
|
@ -109,14 +109,17 @@ class WebSocket:
|
|||||||
self.keep_alive = 0
|
self.keep_alive = 0
|
||||||
return
|
return
|
||||||
|
|
||||||
|
mask_offset = 2
|
||||||
if payload_length == 126:
|
if payload_length == 126:
|
||||||
payload_length = struct.unpack(">H", data[2:4])[0]
|
payload_length = struct.unpack(">H", data[2:4])[0]
|
||||||
|
mask_offset = 4
|
||||||
elif payload_length == 127:
|
elif payload_length == 127:
|
||||||
payload_length = struct.unpack(">Q", data[2:10])[0]
|
payload_length = struct.unpack(">Q", data[2:10])[0]
|
||||||
|
mask_offset = 10
|
||||||
|
|
||||||
masks = data[2:6]
|
masks = data[mask_offset:mask_offset + 4]
|
||||||
decoded = ""
|
decoded = ""
|
||||||
for char in data[6:payload_length + 6]:
|
for char in data[mask_offset + 4:payload_length + mask_offset + 4]:
|
||||||
char ^= masks[len(decoded) % 4]
|
char ^= masks[len(decoded) % 4]
|
||||||
decoded += chr(char)
|
decoded += chr(char)
|
||||||
|
|
||||||
@ -209,4 +212,4 @@ class WebSocket:
|
|||||||
return response_key.decode('ASCII')
|
return response_key.decode('ASCII')
|
||||||
|
|
||||||
def finish(self):
|
def finish(self):
|
||||||
self.protocol.connection_lost(self)
|
self.protocol.connection_lost(self)
|
||||||
|
Loading…
Reference in New Issue
Block a user