Server now actively checks for disconnected users
This commit is contained in:
parent
a9325de8f9
commit
9fc746bd17
@ -16,6 +16,8 @@ class SyncFactory(Factory):
|
|||||||
self._rooms = {}
|
self._rooms = {}
|
||||||
self._roomStates = {}
|
self._roomStates = {}
|
||||||
self.isolateRooms = isolateRooms
|
self.isolateRooms = isolateRooms
|
||||||
|
self._usersCheckupTimer = task.LoopingCall(self._checkUsers)
|
||||||
|
self._usersCheckupTimer.start(4, True)
|
||||||
|
|
||||||
def buildProtocol(self, addr):
|
def buildProtocol(self, addr):
|
||||||
return SyncServerProtocol(self)
|
return SyncServerProtocol(self)
|
||||||
@ -87,6 +89,7 @@ class SyncFactory(Factory):
|
|||||||
watcherProtocol.sendState(position, paused, doSeek, setBy, senderLatency, watcher.latency, forcedUpdate)
|
watcherProtocol.sendState(position, paused, doSeek, setBy, senderLatency, watcher.latency, forcedUpdate)
|
||||||
if(time.time() - watcher.lastUpdate > 4.1):
|
if(time.time() - watcher.lastUpdate > 4.1):
|
||||||
watcherProtocol.drop()
|
watcherProtocol.drop()
|
||||||
|
self.removeWatcher(watcherProtocol)
|
||||||
|
|
||||||
def __updateWatcherPing(self, latencyCalculation, watcher):
|
def __updateWatcherPing(self, latencyCalculation, watcher):
|
||||||
if (latencyCalculation):
|
if (latencyCalculation):
|
||||||
@ -185,6 +188,14 @@ class SyncFactory(Factory):
|
|||||||
for receiver in room:
|
for receiver in room:
|
||||||
what(receiver)
|
what(receiver)
|
||||||
|
|
||||||
|
def _checkUsers(self):
|
||||||
|
for room in self._rooms.itervalues():
|
||||||
|
for watcher in room.itervalues():
|
||||||
|
if(time.time() - watcher.lastUpdate > 4.1):
|
||||||
|
watcher.watcherProtocol.drop()
|
||||||
|
self.removeWatcher(watcher.watcherProtocol)
|
||||||
|
|
||||||
|
|
||||||
class Watcher(object):
|
class Watcher(object):
|
||||||
def __init__(self, factory, watcherProtocol, name, room):
|
def __init__(self, factory, watcherProtocol, name, room):
|
||||||
self.factory = factory
|
self.factory = factory
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user