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))
17 def handleConnected(self):
19 print('CONNECTION FROM:', self.address)
20 connection_id = uuid.uuid4()
21 self.server.clients[connection_id] = self
23 def handleClose(self):
24 print('CONNECTION CLOSED FROM:', self.address)
25 for connection_id in self.server.clients:
26 if self.server.clients[connection_id] == self:
27 del self.server.clients[connection_id]
34 class PlomWebSocketServer(SimpleWebSocketServer):
36 def __init__(self, queue, port, *args, **kwargs):
37 super().__init__('', port, PlomWebSocket)
41 def serve_forever(self):
44 def server_close(self):