"""
raise NotImplementedError
+ def ping(self, data):
+ """Send ping frame to the remote end."""
+ self.ws_connection.write_ping(data)
+
+ def on_pong(self, data):
+ """Invoked when the response to a ping frame is received."""
+ pass
+
def on_close(self):
"""Invoked when the WebSocket is closed."""
pass
assert isinstance(message, bytes_type)
self.stream.write(b("\x00") + message + b("\xff"))
+ def write_ping(self, data):
+ """Send ping frame."""
+ raise ValueError("Ping messages not supported by this version of websockets")
+
def close(self):
"""Closes the WebSocket connection."""
if not self.server_terminated:
assert isinstance(message, bytes_type)
self._write_frame(True, opcode, message)
+ def write_ping(self, data):
+ """Send ping frame."""
+ assert isinstance(data, bytes_type)
+ self._write_frame(True, 0x9, data)
+
def _receive_frame(self):
self.stream.read_bytes(2, self._on_frame_start)
self._write_frame(True, 0xA, data)
elif opcode == 0xA:
# Pong
- pass
+ self.async_callback(self.handler.on_pong)(data)
else:
self._abort()