Ignore:
Timestamp:
Aug 22, 2007, 5:00:48 PM (15 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Convert:
svn:b33ecbfc-034c-dc11-8662-000475d9059e/trunk@5
Message:

Reverse how handlers are associated with the stream manager. Kick version.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wokkel/subprotocols.py

    r1 r4  
    1616from twisted.words.xish.domish import IElement
    1717
    18 from wokkel.iwokkel import IXMPPHandler
     18from wokkel.iwokkel import IXMPPHandler, IXMPPHandlerCollection
    1919
    2020class XMPPHandler(object):
    2121    implements(IXMPPHandler)
     22
     23    def setHandlerParent(self, parent):
     24        self.parent = parent
     25        self.parent.addHandler(self)
     26
     27    def disownHandlerParent(self, parent):
     28        self.parent.removeHandler(self)
     29        self.parent = None
    2230
    2331    def makeConnection(self, xs):
     
    4957                    L{xmlstream.XmlStream} for details.
    5058        """
    51         self.manager.send(obj)
    52 
    53 class XMPPHandlerContainer(object):
    54     """
    55     Container for XMPP subprotocol handlers.
    56     """
     59        self.parent.send(obj)
     60
     61
     62class XMPPHandlerCollection(object):
     63    """
     64    Collection of XMPP subprotocol handlers.
     65
     66    This allows for grouping of subprotocol handlers, but is not an
     67    L{XMPPHandler} itself, so this is not recursive.
     68
     69    @ivar xmlstream: Currently managed XML stream.
     70    @type xmlstream: L{XmlStream}
     71    @ivar handlers: List of protocol handlers.
     72    @type handlers: L{list} of objects providing
     73                      L{IXMPPHandler}
     74    """
     75
     76    implements(IXMPPHandlerCollection)
    5777
    5878    def __init__(self):
     
    7898
    7999        self.handlers.append(handler)
    80         handler.manager = self
    81100
    82101        # get protocol handler up to speed when a connection has already
     
    91110        """
    92111
    93         handler.manager = None
    94112        self.handlers.remove(handler)
    95113
    96 class StreamManager(XMPPHandlerContainer):
     114class StreamManager(XMPPHandlerCollection):
    97115    """
    98116    Business logic representing a managed XMPP connection.
     
    103121    using L{addHandler}.
    104122
    105     @ivar xmlstream: currently managed XML stream
    106     @type xmlstream: L{XmlStream}
    107     @ivar handlers: list of protocol handlers
    108     @type handlers: L{list} of objects providing
    109                       L{IXMPPHandler}
    110123    @ivar logTraffic: if true, log all traffic.
    111124    @type logTraffic: L{bool}
Note: See TracChangeset for help on using the changeset viewer.