diff options
| author | Hornwitser <[email protected]> | 2015-10-16 14:00:39 +0200 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2015-10-16 16:20:04 -0400 |
| commit | 07adb330dbbb75addcdd06bffa06f6605c34aa06 (patch) | |
| tree | e428248e8cf38f1c098a24b7c1646ffe0cd40a15 /discord/client.py | |
| parent | Add Channel.voice_members (diff) | |
| download | discord.py-07adb330dbbb75addcdd06bffa06f6605c34aa06.tar.xz discord.py-07adb330dbbb75addcdd06bffa06f6605c34aa06.zip | |
Add events for sniffing the WebSocket data
Add on_socket_raw_receive and on_socket_raw_send events for sniffing the
data being received and sent on the websocket. Useful for debugging and
logging websocket messages received and sent on the link to Discord's
servers.
Diffstat (limited to 'discord/client.py')
| -rw-r--r-- | discord/client.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/discord/client.py b/discord/client.py index 1df0c812..5d29de7e 100644 --- a/discord/client.py +++ b/discord/client.py @@ -93,7 +93,12 @@ class WebSocket(WebSocketBaseClient): def handshake_ok(self): pass + def send(self, payload, binary=False): + self.dispatch('socket_raw_send', payload, binary) + WebSocketBaseClient.send(self, payload, binary) + def received_message(self, msg): + self.dispatch('socket_raw_receive', msg) response = json.loads(str(msg)) log.debug('WebSocket Event: {}'.format(response)) if response.get('op') != 0: |