Who's lagging behind fix
This commit is contained in:
parent
4696a6126a
commit
4b1d0971a8
@ -78,14 +78,14 @@ class SyncClientProtocol(CommandProtocol):
|
|||||||
message = '%s is present in the room: \'%s\'' % (who, where)
|
message = '%s is present in the room: \'%s\'' % (who, where)
|
||||||
self.__syncplayClient.ui.showMessage(message)
|
self.__syncplayClient.ui.showMessage(message)
|
||||||
|
|
||||||
@argumentCount(4, 5)
|
@argumentCount(4, 6)
|
||||||
def state(self, args):
|
def state(self, args):
|
||||||
args = self.__parseState(args)
|
args = self.__parseState(args)
|
||||||
if not args:
|
if not args:
|
||||||
self.dropWithError('Malformed state attributes')
|
self.dropWithError('Malformed state attributes')
|
||||||
return
|
return
|
||||||
counter, ctime, paused, position, name = args
|
counter, ctime, paused, position, lagger, name = args
|
||||||
self.__syncplayClient.updateGlobalState(counter, ctime, paused, position, name)
|
self.__syncplayClient.updateGlobalState(counter, ctime, paused, position, lagger, name)
|
||||||
|
|
||||||
@argumentCount(3)
|
@argumentCount(3)
|
||||||
def seek(self, args):
|
def seek(self, args):
|
||||||
@ -136,10 +136,12 @@ class SyncClientProtocol(CommandProtocol):
|
|||||||
if len(args) == 4:
|
if len(args) == 4:
|
||||||
counter, ctime, state, position = args
|
counter, ctime, state, position = args
|
||||||
who_changed_state = None
|
who_changed_state = None
|
||||||
|
lagger = None
|
||||||
elif len(args) == 5:
|
elif len(args) == 5:
|
||||||
counter, ctime, state, position, who_changed_state = args
|
counter, ctime, state, position, lagger = args
|
||||||
|
who_changed_state = None
|
||||||
else:
|
else:
|
||||||
return
|
counter, ctime, state, position, lagger, who_changed_state = args
|
||||||
if not state in ('paused', 'playing'):
|
if not state in ('paused', 'playing'):
|
||||||
return
|
return
|
||||||
paused = state == 'paused'
|
paused = state == 'paused'
|
||||||
@ -151,7 +153,7 @@ class SyncClientProtocol(CommandProtocol):
|
|||||||
return
|
return
|
||||||
ctime /= 1000.0
|
ctime /= 1000.0
|
||||||
position /= 1000.0
|
position /= 1000.0
|
||||||
return counter, ctime, paused, position, who_changed_state
|
return counter, ctime, paused, position, lagger, who_changed_state
|
||||||
|
|
||||||
class _MessagesSender(object):
|
class _MessagesSender(object):
|
||||||
def __init__(self, protocol):
|
def __init__(self, protocol):
|
||||||
@ -400,7 +402,7 @@ class SyncplayClientManager(object):
|
|||||||
self.users.currentUser.filesize = unicode(os.path.getsize(path))
|
self.users.currentUser.filesize = unicode(os.path.getsize(path))
|
||||||
self.sendPlaying()
|
self.sendPlaying()
|
||||||
|
|
||||||
def updateGlobalState(self, counter, ctime, paused, position, name):
|
def updateGlobalState(self, counter, ctime, paused, position, lagger, name):
|
||||||
self.counter_recv = max(self.counter_recv, counter)
|
self.counter_recv = max(self.counter_recv, counter)
|
||||||
counter_valid = self.counter and counter >= self.counter
|
counter_valid = self.counter and counter >= self.counter
|
||||||
|
|
||||||
@ -432,8 +434,10 @@ class SyncplayClientManager(object):
|
|||||||
diff = self.getPlayerPosition() - position
|
diff = self.getPlayerPosition() - position
|
||||||
if abs(diff) > 4:
|
if abs(diff) > 4:
|
||||||
self.player.set_position(position)
|
self.player.set_position(position)
|
||||||
#self.player.set_paused(True)
|
if lagger <> self.users.currentUser.name:
|
||||||
message = "Rewinded due to time difference with %s" % name
|
message = "Rewinded due to time difference with %s" % lagger
|
||||||
|
else:
|
||||||
|
message = "You can't seek closer than 8 seconds from where you are"
|
||||||
self.ui.showMessage(message)
|
self.ui.showMessage(message)
|
||||||
|
|
||||||
if self.player_paused and not paused:
|
if self.player_paused and not paused:
|
||||||
|
|||||||
@ -173,14 +173,11 @@ class SyncServerProtocol(CommandProtocol):
|
|||||||
def __init__(self, protocol):
|
def __init__(self, protocol):
|
||||||
self.__protocol = protocol
|
self.__protocol = protocol
|
||||||
|
|
||||||
def send_state(self, counter, ctime, paused, position, who_last_changed):
|
def send_state(self, counter, ctime, paused, position, whosLagging, who_last_changed):
|
||||||
ctime = int(ctime*1000)
|
ctime = int(ctime*1000)
|
||||||
paused = 'paused' if paused else 'playing'
|
paused = 'paused' if paused else 'playing'
|
||||||
position = int(position*1000)
|
position = int(position*1000)
|
||||||
if who_last_changed is None:
|
self.__protocol.sendMessage('state', counter, ctime, paused, position, whosLagging, who_last_changed)
|
||||||
self.__protocol.sendMessage('state', counter, ctime, paused, position)
|
|
||||||
else:
|
|
||||||
self.__protocol.sendMessage('state', counter, ctime, paused, position, who_last_changed)
|
|
||||||
|
|
||||||
def send_seek(self, ctime, position, who_seeked):
|
def send_seek(self, ctime, position, who_seeked):
|
||||||
self.__protocol.sendMessage('seek', int(ctime*1000), int(position*1000), who_seeked)
|
self.__protocol.sendMessage('seek', int(ctime*1000), int(position*1000), who_seeked)
|
||||||
@ -332,12 +329,14 @@ class SyncFactory(Factory):
|
|||||||
if position is None:
|
if position is None:
|
||||||
position, minWatcher = self.find_position(watcher.room)
|
position, minWatcher = self.find_position(watcher.room)
|
||||||
minWatcher = minWatcher.name if minWatcher else None
|
minWatcher = minWatcher.name if minWatcher else None
|
||||||
|
if minWatcher is None and self.pause_change_by is not None:
|
||||||
|
minWatcher = self.pause_change_by.name
|
||||||
curtime = time.time()
|
curtime = time.time()
|
||||||
ctime = curtime - watcher.time_offset
|
ctime = curtime - watcher.time_offset
|
||||||
if self.pause_change_by:
|
if self.pause_change_by:
|
||||||
watcher.watcher_proto.sender.send_state(watcher.counter, ctime, self.paused[watcher.room], position, self.pause_change_by.name)
|
watcher.watcher_proto.sender.send_state(watcher.counter, ctime, self.paused[watcher.room], position, minWatcher, self.pause_change_by.name)
|
||||||
else:
|
else:
|
||||||
watcher.watcher_proto.sender.send_state(watcher.counter, ctime, self.paused[watcher.room], position, minWatcher)
|
watcher.watcher_proto.sender.send_state(watcher.counter, ctime, self.paused[watcher.room], position, minWatcher, None)
|
||||||
watcher.last_update_sent = curtime
|
watcher.last_update_sent = curtime
|
||||||
|
|
||||||
def find_position(self, room):
|
def find_position(self, room):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user