diff --git a/HeliosBackend/__init__.py b/HeliosBackend/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/HeliosBackend/game.py b/HeliosBackend/game.py new file mode 100644 index 0000000..29c0fbc --- /dev/null +++ b/HeliosBackend/game.py @@ -0,0 +1,4 @@ +class Game: + def __init__(self): + self.characters = [] + self.locations = {} \ No newline at end of file diff --git a/HeliosBackend/websockets.py b/HeliosBackend/websockets.py new file mode 100644 index 0000000..cf7a9d3 --- /dev/null +++ b/HeliosBackend/websockets.py @@ -0,0 +1,25 @@ +import asyncio + +import websockets + +class WebSocketConnection: + def __init__(self, websocket: websockets.ServerConnection): + self.websocket = websocket + + +class WebSocketServer: + def __init__(self, port): + self.port = port + + self.connections: set[websockets.ServerConnection] = set() + + async def handler(self, websocket: websockets.ServerConnection): + self.connections.add(websocket) + try: + pass # Do something with the websocket + finally: + self.connections.remove(websocket) + + async def start(self): + async with websockets.serve(self.handler, "", self.port): + await asyncio.Future() \ No newline at end of file