From: Christian Heller Date: Thu, 22 Oct 2020 21:13:33 +0000 (+0200) Subject: Add basic websocket architecture. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/unset_cookie?a=commitdiff_plain;h=428ee9d0d967f1d9d86ea55458ee181e736d7e8a;p=plomrogue2-experiments Add basic websocket architecture. --- diff --git a/new2/websocket_client.html b/new2/websocket_client.html new file mode 100644 index 0000000..e91e4ef --- /dev/null +++ b/new2/websocket_client.html @@ -0,0 +1,74 @@ + + + + + + + + diff --git a/new2/websocket_server.py b/new2/websocket_server.py new file mode 100755 index 0000000..f775776 --- /dev/null +++ b/new2/websocket_server.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 +from SimpleWebSocketServer import SimpleWebSocketServer, WebSocket + +game = {'turn': 0} + +class GameServer(WebSocket): + + def handleMessage(self): + self.sendMessage('TURN: %s' % game['turn']) + game['turn'] += 1 + +server = SimpleWebSocketServer('', 8000, GameServer) +server.serveforever()