mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-14 09:50:03 +00:00
Change on_socket_raw_receive to dispatch right before JSON conversion
This commit is contained in:
parent
ef79305961
commit
78598d59d7
@ -420,8 +420,6 @@ class DiscordWebSocket:
|
|||||||
_log.info('Shard ID %s has sent the RESUME payload.', self.shard_id)
|
_log.info('Shard ID %s has sent the RESUME payload.', self.shard_id)
|
||||||
|
|
||||||
async def received_message(self, msg, /):
|
async def received_message(self, msg, /):
|
||||||
self.log_receive(msg)
|
|
||||||
|
|
||||||
if type(msg) is bytes:
|
if type(msg) is bytes:
|
||||||
self._buffer.extend(msg)
|
self._buffer.extend(msg)
|
||||||
|
|
||||||
@ -430,6 +428,8 @@ class DiscordWebSocket:
|
|||||||
msg = self._zlib.decompress(self._buffer)
|
msg = self._zlib.decompress(self._buffer)
|
||||||
msg = msg.decode('utf-8')
|
msg = msg.decode('utf-8')
|
||||||
self._buffer = bytearray()
|
self._buffer = bytearray()
|
||||||
|
|
||||||
|
self.log_receive(msg)
|
||||||
msg = utils._from_json(msg)
|
msg = utils._from_json(msg)
|
||||||
|
|
||||||
_log.debug('For Shard ID %s: WebSocket Event: %s', self.shard_id, msg)
|
_log.debug('For Shard ID %s: WebSocket Event: %s', self.shard_id, msg)
|
||||||
|
10
docs/api.rst
10
docs/api.rst
@ -312,9 +312,9 @@ to handle it, which defaults to print a traceback and ignoring the exception.
|
|||||||
|
|
||||||
.. function:: on_socket_raw_receive(msg)
|
.. function:: on_socket_raw_receive(msg)
|
||||||
|
|
||||||
Called whenever a message is received from the WebSocket, before
|
Called whenever a message is completely received from the WebSocket, before
|
||||||
it's processed. This event is always dispatched when a message is
|
it's processed and parsed. This event is always dispatched when a
|
||||||
received and the passed data is not processed in any way.
|
complete message is received and the passed data is not parsed in any way.
|
||||||
|
|
||||||
This is only really useful for grabbing the WebSocket stream and
|
This is only really useful for grabbing the WebSocket stream and
|
||||||
debugging purposes.
|
debugging purposes.
|
||||||
@ -327,9 +327,7 @@ to handle it, which defaults to print a traceback and ignoring the exception.
|
|||||||
WebSocket. The voice WebSocket will not trigger this event.
|
WebSocket. The voice WebSocket will not trigger this event.
|
||||||
|
|
||||||
:param msg: The message passed in from the WebSocket library.
|
:param msg: The message passed in from the WebSocket library.
|
||||||
Could be :class:`bytes` for a binary message or :class:`str`
|
:type msg: :class:`str`
|
||||||
for a regular message.
|
|
||||||
:type msg: Union[:class:`bytes`, :class:`str`]
|
|
||||||
|
|
||||||
.. function:: on_socket_raw_send(payload)
|
.. function:: on_socket_raw_send(payload)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user