From 428ee9d0d967f1d9d86ea55458ee181e736d7e8a Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Thu, 22 Oct 2020 23:13:33 +0200 Subject: [PATCH] Add basic websocket architecture. --- new2/websocket_client.html | 74 ++++++++++++++++++++++++++++++++++++++ new2/websocket_server.py | 13 +++++++ 2 files changed, 87 insertions(+) create mode 100644 new2/websocket_client.html create mode 100755 new2/websocket_server.py 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() -- 2.30.2