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.
This commit is contained in:
Hornwitser authored and Rapptz committed 2015-10-16 16:20:04 -04:00
1 parent be14fd1dcc
commit 07adb330db
2 files changed
+42

No files matched your search

+5
View File
@@ -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: