1 from SimpleWebSocketServer import SimpleWebSocketServer, WebSocket
5 class PlomWebSocket(WebSocket):
7 def handleMessage(self):
8 if self.data == 'QUIT':
9 self.sendMessage('BYE')
12 for connection_id in self.server.clients:
13 if self.server.clients[connection_id] == self:
14 self.server.queue.put((connection_id, self.data))
16 def handleConnected(self):
18 print('CONNECTION FROM:', self.address)
19 connection_id = uuid.uuid4()
20 self.server.clients[connection_id] = self
22 def handleClose(self):
23 print('CONNECTION CLOSED FROM:', self.address)
24 for connection_ids in self.server.clients:
25 if self.server.clients[connection_id] == self:
26 del self.server.clients[connection_id]
33 class PlomWebSocketServer(SimpleWebSocketServer):
35 def __init__(self, queue, port, *args, **kwargs):
36 super().__init__('', port, PlomWebSocket)
40 def serve_forever(self):
43 def server_close(self):