Exemple #1
0
 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]
Exemple #2
0
 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]
Exemple #3
0
    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
Exemple #4
0
    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
Exemple #5
0
    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
Exemple #6
0
    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
Exemple #7
0
 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'))
Exemple #8
0
 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'))