Closed kalissar30 closed 7 years ago
Seems like a nice way of running the socket server, example code could be:
class ExampleConnection(WebSocket):
def handleMessage(self):
# echo message back to client
self.sendMessage(self.data)
def handleConnected(self):
print(self.address, 'connected')
def handleClose(self):
print(self.address, 'closed')
server = SimpleWebSocketServer('', 8000, ExampleConnection)
while True:
try:
server.serveonce()
except KeyboardInterrupt:
server.close()
break
👍
Yeah looks ok to me.
And serveforever is simply a while True over serveonce
It makes it simpler to customize a socket.