Преглед изворни кода

WebSocket.send_close() now also sends reason in payload

Taddeus Kroes пре 13 година
родитељ
комит
9f7b6c8670
1 измењених фајлова са 4 додато и 1 уклоњено
  1. 4 1
      websocket.py

+ 4 - 1
websocket.py

@@ -151,7 +151,10 @@ class WebSocket(object):
         return thread
 
     def send_close(self, code, reason):
-        payload = '' if code is None else struct.pack('!H', code)
+        """
+        Send a close control frame.
+        """
+        payload = '' if code is None else struct.pack('!H', code) + reason
         self.send_frame(ControlFrame(OPCODE_CLOSE, payload))
         self.close_frame_sent = True