From 457b6bc63309242a1cc063e1c6ad1125ca915f0c Mon Sep 17 00:00:00 2001 From: Et0h Date: Sat, 24 Jan 2015 10:35:54 +0000 Subject: [PATCH] Add --disable-ready server arg to turn off readiness feature --- syncplay/messages.py | 3 +++ syncplay/server.py | 8 ++++++-- syncplayServer.py | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/syncplay/messages.py b/syncplay/messages.py index b8eb27c..fff09cb 100755 --- a/syncplay/messages.py +++ b/syncplay/messages.py @@ -326,6 +326,7 @@ en = { "server-password-argument" : 'server password', "server-isolate-room-argument" : 'should rooms be isolated?', "server-salt-argument" : "random string used to generate controlled room passwords", + "server-disable-ready-argument" : u"disable readiness feature", "server-motd-argument": "path to file from which motd will be fetched", "server-messed-up-motd-unescaped-placeholders": "Message of the Day has unescaped placeholders. All $ signs should be doubled ($$).", "server-messed-up-motd-too-long": "Message of the Day is too long - maximum of {} chars, {} given.", @@ -665,6 +666,7 @@ ru = { "server-password-argument" : u'пароль к серверу', "server-isolate-room-argument" : u'должны ли комнаты быть изолированными?', "server-salt-argument" : u"random string used to generate controlled room passwords", # TODO: Translate into Russian (note: as you may already be aware, 'salt' means Соль (криптография)) + "server-disable-ready-argument" : u"disable readiness feature", # TODO: Translate into Russian "server-motd-argument" : u"путь к файлу, из которого будет извлекаться MOTD-сообщение", "server-messed-up-motd-unescaped-placeholders" : u"MOTD-сообщение содержит неэкранированные спец.символы. Все знаки $ должны быть продублированы ($$).", "server-messed-up-motd-too-long" : u"MOTD-сообщение слишком длинное: максимальная длина - {} символ(ов), текущая длина - {} символ(ов).", @@ -1004,6 +1006,7 @@ de = { "server-password-argument" : u'Server Passwort', "server-isolate-room-argument" : u'Sollen die Räume isoliert sein?', "server-salt-argument" : u"zufällige Zeichenkette, die zur Erstellung von Passwörtern verwendet wird", + "server-disable-ready-argument" : u"disable readiness feature", # TODO: Translate into German "server-motd-argument": u"Pfad zur Datei, von der die Nachricht des Tages geladen wird", "server-messed-up-motd-unescaped-placeholders": u"Die Nachricht des Tages hat unmaskierte Platzhalter. Alle $-Zeichen sollten verdoppelt werden ($$).", "server-messed-up-motd-too-long": u"Die Nachricht des Tages ist zu lang - Maximal {} Zeichen, aktuell {}.", diff --git a/syncplay/server.py b/syncplay/server.py index 7a38681..3996311 100644 --- a/syncplay/server.py +++ b/syncplay/server.py @@ -14,7 +14,7 @@ import argparse from syncplay.utils import RoomPasswordProvider, NotControlledRoom, RandomStringGenerator, meetsMinVersion class SyncFactory(Factory): - def __init__(self, password='', motdFilePath=None, isolateRooms=False, salt=None): + def __init__(self, password='', motdFilePath=None, isolateRooms=False, salt=None, disableReady=False): print getMessage("welcome-server-notification").format(syncplay.version) if password: password = hashlib.md5(password).hexdigest() @@ -24,6 +24,7 @@ class SyncFactory(Factory): print getMessage("no-salt-notification").format(salt) self._salt = salt self._motdFilePath = motdFilePath + self.disableReady = disableReady if not isolateRooms: self._roomManager = RoomManager() else: @@ -129,7 +130,7 @@ class SyncFactory(Factory): def setReady(self, watcher, isReady, manuallyInitiated=True): watcher.setReady(isReady) - self._roomManager.broadcastRoom(watcher, lambda w: w.sendSetReady(watcher.getName(), isReady, manuallyInitiated)) + self._roomManager.broadcastRoom(watcher, lambda w: w.sendSetReady(watcher.getName(), watcher.isReady(), manuallyInitiated)) class RoomManager(object): def __init__(self): @@ -332,6 +333,8 @@ class Watcher(object): self._ready = ready def isReady(self): + if self._server.disableReady: + return None return self._ready def getRoom(self): @@ -437,5 +440,6 @@ class ConfigurationGetter(object): self._argparser.add_argument('--port', metavar='port', type=str, nargs='?', help=getMessage("server-port-argument")) self._argparser.add_argument('--password', metavar='password', type=str, nargs='?', help=getMessage("server-password-argument")) self._argparser.add_argument('--isolate-rooms', action='store_true', help=getMessage("server-isolate-room-argument")) + self._argparser.add_argument('--disable-ready', action='store_true', help=getMessage("server-disable-ready-argument")) self._argparser.add_argument('--salt', metavar='salt', type=str, nargs='?', help=getMessage("server-salt-argument")) self._argparser.add_argument('--motd-file', metavar='file', type=str, nargs='?', help=getMessage("server-motd-argument")) \ No newline at end of file diff --git a/syncplayServer.py b/syncplayServer.py index 23b5381..b4456d7 100755 --- a/syncplayServer.py +++ b/syncplayServer.py @@ -20,5 +20,5 @@ if __name__ == '__main__': argsGetter = ConfigurationGetter() args = argsGetter.getConfiguration() - reactor.listenTCP(int(args.port), SyncFactory(args.password, args.motd_file, args.isolate_rooms, args.salt)) + reactor.listenTCP(int(args.port), SyncFactory(args.password, args.motd_file, args.isolate_rooms, args.salt, args.disable_ready)) reactor.run()