def connectionLost(self, xs, reason): """Called from the handler when connection to a client is lost.""" if xs.otherEntity is not None: userid, resource = util.jid_to_userid(xs.otherEntity, True) if userid in self.streams and resource in self.streams[userid] and self.streams[userid][resource] == xs.manager: del self.streams[userid][resource] if len(self.streams[userid]) == 0: del self.streams[userid]
def connectionLost(self, xs, reason): """Called from the handler when connection to a client is lost.""" if xs.otherEntity is not None: userid, resource = util.jid_to_userid(xs.otherEntity, True) if userid in self.streams and resource in self.streams[ userid] and self.streams[userid][resource] == xs.manager: del self.streams[userid][resource] if len(self.streams[userid]) == 0: del self.streams[userid]
def connectionInitialized(self, xs): """Called from the handler when a client has authenticated.""" userid, resource = util.jid_to_userid(xs.otherEntity, True) if userid not in self.streams: self.streams[userid] = {} if resource in self.streams[userid]: log.debug("resource conflict for %s" % (xs.otherEntity, )) self.streams[userid][resource].conflict() self.streams[userid][resource] = xs.manager
def client_connected(self, _jid): """Return true if the given L{JID} is found connected locally.""" userid, resource = util.jid_to_userid(_jid, True) if userid in self.streams: if resource: return resource in self.streams[userid] else: return len(self.streams[userid]) > 0 return False
def test_jid_to_userid(self): jid = JID('[email protected]/resource') userid = util.jid_to_userid(jid, splitted=False) self.assertEqual(userid, 'userresource') userid = util.jid_to_userid(jid, splitted=True) self.assertTupleEqual(userid, ('user', 'resource'))