aboutsummaryrefslogtreecommitdiff
path: root/discord
diff options
context:
space:
mode:
authorHornwitser <[email protected]>2015-10-16 14:00:39 +0200
committerRapptz <[email protected]>2015-10-16 16:20:04 -0400
commit07adb330dbbb75addcdd06bffa06f6605c34aa06 (patch)
treee428248e8cf38f1c098a24b7c1646ffe0cd40a15 /discord
parentAdd Channel.voice_members (diff)
downloaddiscord.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')
-rw-r--r--discord/client.py5
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: