Simple refactoring

This commit is contained in:
Uriziel 2013-07-03 13:08:26 +02:00
parent 7e0b127923
commit 1f49b49edf

View File

@ -200,6 +200,16 @@ class SyncFactory(Factory):
self._roomStates[watcher.room]["setBy"] = setter.name self._roomStates[watcher.room]["setBy"] = setter.name
self._roomStates[watcher.room]["lastUpdate"] = setter.lastUpdate self._roomStates[watcher.room]["lastUpdate"] = setter.lastUpdate
def __notifyIrcBot(self, position, paused, doSeek, watcher, oldPosition, pauseChanged):
if (self.ircVerbose):
if (paused and pauseChanged):
self.ircBot.sp_paused(watcher.name, watcher.room)
elif (not paused and pauseChanged):
self.ircBot.sp_unpaused(watcher.name, watcher.room)
if (doSeek and position):
self.ircBot.sp_seek(watcher.name, oldPosition, position, watcher.room)
def updateWatcherState(self, watcherProtocol, position, paused, doSeek, latencyCalculation): def updateWatcherState(self, watcherProtocol, position, paused, doSeek, latencyCalculation):
watcher = self.getWatcher(watcherProtocol) watcher = self.getWatcher(watcherProtocol)
self.__updateWatcherPing(latencyCalculation, watcher) self.__updateWatcherPing(latencyCalculation, watcher)
@ -213,13 +223,7 @@ class SyncFactory(Factory):
self.__updatePositionState(position, doSeek or pauseChanged, watcher) self.__updatePositionState(position, doSeek or pauseChanged, watcher)
forceUpdate = self.__shouldServerForceUpdateOnRoom(pauseChanged, doSeek) forceUpdate = self.__shouldServerForceUpdateOnRoom(pauseChanged, doSeek)
if(forceUpdate): if(forceUpdate):
if(self.ircVerbose): self.__notifyIrcBot(position, paused, doSeek, watcher, oldPosition, pauseChanged)
if(paused and pauseChanged):
self.ircBot.sp_paused(watcher.name, watcher.room)
elif(not paused and pauseChanged):
self.ircBot.sp_unpaused(watcher.name, watcher.room)
if(doSeek and position):
self.ircBot.sp_seek(watcher.name, oldPosition, position, watcher.room)
l = lambda w: self.sendState(w, doSeek, watcher.latency, forceUpdate) l = lambda w: self.sendState(w, doSeek, watcher.latency, forceUpdate)
self.broadcastRoom(watcher.watcherProtocol, l) self.broadcastRoom(watcher.watcherProtocol, l)