From: <Blu...@us...> - 2010-04-21 15:18:44
|
Revision: 336 http://virtplayground.svn.sourceforge.net/virtplayground/?rev=336&view=rev Author: BlueWolf_ Date: 2010-04-21 15:18:38 +0000 (Wed, 21 Apr 2010) Log Message: ----------- Added callback.leaves_vp. callback.enters_vp and callback.leaves_vp both have a cid as argument now. Modified Paths: -------------- trunk/server/core/callback.py trunk/server/core/parser.py trunk/server/core/server.py Modified: trunk/server/core/callback.py =================================================================== --- trunk/server/core/callback.py 2010-04-19 19:44:41 UTC (rev 335) +++ trunk/server/core/callback.py 2010-04-21 15:18:38 UTC (rev 336) @@ -203,10 +203,18 @@ """ return True - def enters_vp(self, client): + def enters_vp(self, cid): """ Called when a client is logged in and enters VP. - client: - Same as server.clients[cid] + cid: + The unique ID for this connection. (connection-id) """ + + def leaves_vp(self, cid): + """ + Called when a logged-in client has gone offline. + + cid: + The unique ID for this connection. (connection-id) + """ Modified: trunk/server/core/parser.py =================================================================== --- trunk/server/core/parser.py 2010-04-19 19:44:41 UTC (rev 335) +++ trunk/server/core/parser.py 2010-04-21 15:18:38 UTC (rev 336) @@ -71,7 +71,7 @@ def _is_client_visible(self, client1, client2): """ - Checks is client1 can see client2 + Checks if client1 can see client2 """ client1 = client1['pos'] @@ -100,7 +100,7 @@ Send when the users wants to log in usr - The username pwd - The (rsa encrypted) sha-password - bot - Whether the it's an bot or an user + bot - Whether it's an bot or an user for - For what services it's logging in "VP" - VP client client - list with [app_name, app_version] @@ -262,5 +262,5 @@ data.send("userlist", userlist) - self.call.enters_vp(client) + self.call.enters_vp(cid) Modified: trunk/server/core/server.py =================================================================== --- trunk/server/core/server.py 2010-04-19 19:44:41 UTC (rev 335) +++ trunk/server/core/server.py 2010-04-21 15:18:38 UTC (rev 336) @@ -270,16 +270,16 @@ # Was this user already online? client = self.__clients[self.__cid] if client['status'] == 'VP': - + # Tell other users this one has gone offline for cid, cl in self.__clients.items(): if cid == self.__cid: continue + if cl['status'] == 'VP': + cl['con'].send("useroffline", { + "cid": self.__cid, + "reason": reason + }) - cl['con'].send("useroffline", { - "cid": self.__cid, - "reason": reason - }) - def run(self): """ @@ -341,6 +341,11 @@ except: pass self.__sock.close() + # Was this user already online? + client = self.__clients[self.__cid] + if client['status'] == 'VP': + self.__call.leaves_vp(self.__cid) + self.__call.connection_closed(self.__cid, reason) self.__notify_offline(reason) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |