plugins room_games, radiocol: better synchronization after a user joins a running game

This commit is contained in:
souliane 2014-01-15 23:01:23 +01:00
commit 9e6845472d

View file

@ -224,8 +224,16 @@ class Radiocol(object):
else:
error(_('Unmanaged game element: %s') % elt.name)
def getSyncData(self, room_jid_s):
data = self.games[room_jid_s]['queue']
if len(data) == QUEUE_LIMIT:
data.append(domish.Element((None, 'no_upload')))
def getSyncData(self, room_jid_s, force_nicks=[]):
data = {}
status = self.games[room_jid_s]['status']
nicks = [nick for nick in status if status[nick] == 'desync']
for nick in force_nicks:
if nick not in nicks:
nicks.append(nick)
for nick in nicks:
if len(self.games[room_jid_s]['queue']) > 0:
data[nick] = copy.deepcopy(self.games[room_jid_s]['queue'])
if len(self.games[room_jid_s]['queue']) == QUEUE_LIMIT:
data[nick].append(domish.Element(('', 'no_upload')))
return data