From e5dc3135aa140671a7b11571aa8c7c1e85c2ad15 Mon Sep 17 00:00:00 2001 From: Uriziel Date: Tue, 16 Oct 2012 17:11:24 +0200 Subject: [PATCH] Improvements in userlist handling --- syncplay/client.py | 7 +++++-- syncplay/protocols.py | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/syncplay/client.py b/syncplay/client.py index 8bc9075..0a0657c 100644 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -396,7 +396,7 @@ class SyncplayUserlist(object): def __addDifferentFileMessageIfNecessary(self, user, message): if(self.currentUser.file): - fileHasSameSizeAsYour = user.file['size'] != self.currentUser.file['size'] + fileHasSameSizeAsYour = user.file['size'] == self.currentUser.file['size'] differentFileMessage = " (but their file size is different from yours!)" message += differentFileMessage if not fileHasSameSizeAsYour else "" return message @@ -426,7 +426,10 @@ class SyncplayUserlist(object): rooms = {} self.__createListOfPeople(rooms) self.__displayListOfPeople(rooms) - + + def clearList(self): + self._users = {} + class UiManager(object): def __init__(self, client, ui): self._client = client diff --git a/syncplay/protocols.py b/syncplay/protocols.py index 6e7e6bb..713e232 100644 --- a/syncplay/protocols.py +++ b/syncplay/protocols.py @@ -89,6 +89,7 @@ class SyncClientProtocol(JSONCommandProtocol): self._client.setRoom(roomName) self.logged = True self._client.sendFile() + self.sendList() def sendHello(self): hello = {} @@ -136,6 +137,7 @@ class SyncClientProtocol(JSONCommandProtocol): self.sendSet({"file": file_}) def handleList(self, userList): + self._client.userlist.clearList() for room in userList.iteritems(): roomName = room[0] for user in room[1].iteritems(): @@ -274,8 +276,7 @@ class SyncServerProtocol(JSONCommandProtocol): self._factory.addWatcher(self, username, roomName, roomPassword) self._logged = True self.sendHello() - self.sendList() - + def sendHello(self): hello = {} hello["username"] = self._factory.watcherGetUsername(self)