From f70cbe44b326f7f67cd6a81fda2e6cebc87be9fd Mon Sep 17 00:00:00 2001 From: Bui Date: Sat, 3 Nov 2018 15:21:21 +0000 Subject: [PATCH] allow multiplayer port to be changed --- server.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index 9270c8f..4b8fe4c 100644 --- a/server.py +++ b/server.py @@ -4,6 +4,7 @@ import asyncio import websockets import json import random +import sys server_status = { "waiting": {}, @@ -314,7 +315,9 @@ async def connection(ws, path): elif user["action"] == "invite" and user["session"] in server_status["invites"]: del server_status["invites"][user["session"]] +port = int(sys.argv[1]) if len(sys.argv) > 1 else 34802 +print('Starting server on port %d' % port) asyncio.get_event_loop().run_until_complete( - websockets.serve(connection, "localhost", 34802) + websockets.serve(connection, "localhost", port) ) asyncio.get_event_loop().run_forever()