Implemented 'Pause when user disconnects'

This commit is contained in:
Uriziel 2013-10-27 17:24:28 +01:00
parent 91a0998ee4
commit c9c8d537b5
2 changed files with 12 additions and 2 deletions

View File

@ -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):

View File

@ -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_)