From c9c8d537b54ad3b8f3a8e2ee39c07d14bfb709ab Mon Sep 17 00:00:00 2001 From: Uriziel Date: Sun, 27 Oct 2013 17:24:28 +0100 Subject: [PATCH] Implemented 'Pause when user disconnects' --- syncplay/client.py | 12 +++++++++++- syncplay/protocols.py | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/syncplay/client.py b/syncplay/client.py index 3ae2edc..b43fd9c 100644 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -33,6 +33,8 @@ class SyncClientFactory(ClientFactory): self._client.ui.showMessage(message) def clientConnectionLost(self, connector, reason): + if self._timesTried == 0: + self._client.onDisconnect() if self._timesTried < self.retry: self._timesTried += 1 self._client.ui.showMessage(getMessage("en", "reconnection-attempt-notification")) @@ -248,7 +250,15 @@ class SyncplayClient(object): self._userOffset = time self.setPosition(self.getGlobalPosition()) self.ui.showMessage(getMessage("en", "current-offset-notification").format(self._userOffset)) - + + def onDisconnect(self): + if(self._config['pauseOnLeave']): + self.setPaused(True) + + def removeUser(self, username): + self.onDisconnect() + self.userlist.removeUser(username) + def getPlayerPosition(self): if(not self._lastPlayerUpdate): if(self._lastGlobalUpdate): diff --git a/syncplay/protocols.py b/syncplay/protocols.py index 8680c1a..171a4ef 100644 --- a/syncplay/protocols.py +++ b/syncplay/protocols.py @@ -119,7 +119,7 @@ class SyncClientProtocol(JSONCommandProtocol): if(settings["event"].has_key("joined")): self._client.userlist.addUser(username, room, file_) elif(settings["event"].has_key("left")): - self._client.userlist.removeUser(username) + self._client.removeUser(username) else: self._client.userlist.modUser(username, room, file_)