Changeset 70:cc8ecefb5519 in ralphm-patches


Ignore:
Timestamp:
Oct 27, 2012, 1:59:00 AM (7 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

Move session lookup changes to session_manager.patch.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c2s_stanza_handlers.patch

    r69 r70  
    11# HG changeset patch
    2 # Parent eb898b91399636715feb9530c3d3e0090628926a
     2# Parent d387959177865c2f964eb013df21986a2f9020e9
    33Add c2s protocol handlers for iq, message and presence stanzas.
    44
     
    9595+
    9696+sessionManager.connectionManager = c2sFactory
    97 diff --git a/wokkel/client.py b/wokkel/client.py
    98 --- a/wokkel/client.py
    99 +++ b/wokkel/client.py
    100 @@ -589,13 +589,38 @@
    101          return defer.succeed(entity)
    102  
    103  
    104 +    def lookupSessions(self, entity):
    105 +        """
    106 +        Return all sessions for a user.
    107 +
    108 +        @param entity: Entity to retrieve sessions for. This the resource part
    109 +            will be ignored.
    110 +        @type entity: L{JID<twisted.words.protocols.jabber.jid.JID>}
    111 +
    112 +        @return: Mapping of sessions keyed by resource.
    113 +        @rtype: C{dict}
    114 +        """
    115 +        localpart = entity.user
    116 +
    117 +        try:
    118 +            return self.sessions[localpart]
    119 +        except:
    120 +            return {}
    121 +
    122 +
    123      def lookupSession(self, entity):
    124 -        localpart = entity.user
    125 -        resource = entity.resource
    126 +        """
    127 +        Return the session for a particular resource of an entity.
    128  
    129 -        userSessions = self.sessions[localpart]
    130 -        session = userSessions[resource]
    131 -        return session
    132 +        @param entity: Entity to retrieve sessions for.
    133 +        @type entity: L{JID<twisted.words.protocols.jabber.jid.JID>}
    134 +
    135 +        @return: C{UserSession}.
    136 +        """
    137 +
    138 +        userSessions = self.lookupSessions(entity)
    139 +        return userSessions[entity.resource]
    140 +
    141  
    142  
    143      def unbindResource(self, session, reason=None):
    14497diff --git a/wokkel/test/test_xmppim.py b/wokkel/test/test_xmppim.py
    14598--- a/wokkel/test/test_xmppim.py
  • session_manager.patch

    r68 r70  
    11# HG changeset patch
    2 # Parent 53e7ea0d847e61f209fe37359380c8c58e0ece72
     2# Parent bc450d2e7ed710c5605545e39bb6a054c368571f
    33
    44diff --git a/wokkel/client.py b/wokkel/client.py
     
    3232 NS_CLIENT = 'jabber:client'
    3333 
    34 @@ -479,3 +483,161 @@
     34@@ -482,3 +486,186 @@
    3535         return [
    3636             generic.StanzaForwarder()
     
    139139+
    140140+
     141+    def lookupSessions(self, entity):
     142+        """
     143+        Return all sessions for a user.
     144+
     145+        @param entity: Entity to retrieve sessions for. This the resource part
     146+            will be ignored.
     147+        @type entity: L{JID<twisted.words.protocols.jabber.jid.JID>}
     148+
     149+        @return: Mapping of sessions keyed by resource.
     150+        @rtype: C{dict}
     151+        """
     152+        localpart = entity.user
     153+
     154+        try:
     155+            return self.sessions[localpart]
     156+        except:
     157+            return {}
     158+
     159+
    141160+    def lookupSession(self, entity):
    142 +        localpart = entity.user
    143 +        resource = entity.resource
    144 +
    145 +        userSessions = self.sessions[localpart]
    146 +        session = userSessions[resource]
    147 +        return session
     161+        """
     162+        Return the session for a particular resource of an entity.
     163+
     164+        @param entity: Entity to retrieve sessions for.
     165+        @type entity: L{JID<twisted.words.protocols.jabber.jid.JID>}
     166+
     167+        @return: C{UserSession}.
     168+        """
     169+
     170+        userSessions = self.lookupSessions(entity)
     171+        return userSessions[entity.resource]
     172+
    148173+
    149174+
Note: See TracChangeset for help on using the changeset viewer.