X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;f=new2%2Fplomrogue%2Fio.py;h=8e0f9bf530548572eb7c07d389d7188e19af47d1;hb=HEAD;hp=5450c343a031a721c64ae70289719f40729b1a7f;hpb=61e7b58cf8be7a0c24d78a1336e54fdbf088deea;p=plomrogue2-experiments
diff --git a/new2/plomrogue/io.py b/new2/plomrogue/io.py
index 5450c34..8e0f9bf 100644
--- a/new2/plomrogue/io.py
+++ b/new2/plomrogue/io.py
@@ -1,5 +1,6 @@
import queue
import threading
+import inspect
@@ -30,12 +31,15 @@ class GameIO():
c = threading.Thread(target=self.loop, args=(self.queue,))
c.start()
- def start_server(self, port, server_class):
+ def start_server(self, port, server_class, certfile=None, keyfile=None):
"""Start server of server_class in talk with game loop.
The server communicates with the game loop via self.queue.
"""
- server = server_class(self.queue, port)
+ if 'certfile' in list(inspect.signature(server_class.__init__).parameters):
+ server = server_class(self.queue, port, certfile=certfile, keyfile=keyfile)
+ else:
+ server = server_class(self.queue, port)
self.servers += [server]
c = threading.Thread(target=server.serve_forever)
c.start()
@@ -47,7 +51,6 @@ class GameIO():
signature will only be called if god_mode is set.
"""
- from inspect import signature
from plomrogue.errors import GameError, ArgError, PlayError
from plomrogue.misc import quote
@@ -62,7 +65,7 @@ class GameIO():
if command is None:
answer(connection_id, 'UNHANDLED_INPUT')
else:
- if 'connection_id' in list(signature(command).parameters):
+ if 'connection_id' in list(inspect.signature(command).parameters):
command(*args, connection_id=connection_id)
elif god_mode:
command(*args)