mirror of https://gitlab.com/litecord/litecord.git
gateway.websocket: fix etf
This commit is contained in:
parent
b6da5ad9d3
commit
9f50721243
|
|
@ -227,6 +227,7 @@ class GatewayWebsocket:
|
|||
payload.get('s'),
|
||||
payload.get('t'))
|
||||
|
||||
# treat encoded as bytes
|
||||
if not isinstance(encoded, bytes):
|
||||
encoded = encoded.encode()
|
||||
|
||||
|
|
@ -237,7 +238,13 @@ class GatewayWebsocket:
|
|||
# should do all?
|
||||
await self.ws.send(zlib.compress(encoded))
|
||||
else:
|
||||
try:
|
||||
# assume encoded is string, json based, decoding it
|
||||
# should give reasonable messages down the websocket
|
||||
await self.ws.send(encoded.decode())
|
||||
except UnicodeDecodeError:
|
||||
# in here, encoded is ETF, its bytes(), so we send it raw
|
||||
await self.ws.send(encoded)
|
||||
|
||||
async def send_op(self, op_code: int, data: Any):
|
||||
"""Send a packet but just the OP code information is filled in."""
|
||||
|
|
|
|||
Loading…
Reference in New Issue