handle timeouts and disconnects properly

This commit is contained in:
Miguel Grinberg 2017-02-24 18:09:32 -08:00
parent 40ccb4a0dd
commit 7560660ec7

View File

@ -10,6 +10,16 @@ class WebSocketProtocol(HttpProtocol):
super().__init__(*args, **kwargs)
self.websocket = None
def connection_timeout(self):
# timeouts make no sense for websocket routes
if self.websocket is None:
super().connection_timeout()
def connection_lost(self, exc):
if self.websocket is not None:
self.websocket.connection_lost(exc)
super().connection_lost(exc)
def data_received(self, data):
if self.websocket is not None:
# pass the data to the websocket protocol