예제 #1
0
class DeferredClientFactory(XmlStreamFactoryMixin, protocol.ClientFactory):
    protocol = xmlstream.XmlStream

    def __init__(self, jid, password):
        self.authenticator = client.XMPPAuthenticator(jid, password)
        XmlStreamFactoryMixin.__init__(self, self.authenticator)

        deferred = defer.Deferred()
        self.deferred = deferred

        self.addBootstrap(xmlstream.INIT_FAILED_EVENT, deferred.errback)

        class ConnectionInitializedHandler(XMPPHandler):
            def connectionInitialized(self):
                deferred.callback(None)

        self.streamManager = StreamManager(self)
        self.addHandler(ConnectionInitializedHandler())

    def clientConnectionFailed(self, connector, reason):
        self.deferred.errback(reason)

    def addHandler(self, handler):
        """
        Add a subprotocol handler to the stream manager.
        """
        self.streamManager.addHandler(handler)

    def removeHandler(self, handler):
        """
        Add a subprotocol handler to the stream manager.
        """
        self.streamManager.removeHandler(handler)
예제 #2
0
파일: client.py 프로젝트: ralphm/wokkel
class DeferredClientFactory(generic.DeferredXmlStreamFactory):
    def __init__(self, jid, password):
        authenticator = client.XMPPAuthenticator(jid, password)
        generic.DeferredXmlStreamFactory.__init__(self, authenticator)
        self.streamManager = StreamManager(self)

    def addHandler(self, handler):
        """
        Add a subprotocol handler to the stream manager.
        """
        self.streamManager.addHandler(handler)

    def removeHandler(self, handler):
        """
        Add a subprotocol handler to the stream manager.
        """
        self.streamManager.removeHandler(handler)
예제 #3
0
파일: client.py 프로젝트: Gandi/wokkel
class DeferredClientFactory(generic.DeferredXmlStreamFactory):
    def __init__(self, jid, password):
        authenticator = client.XMPPAuthenticator(jid, password)
        generic.DeferredXmlStreamFactory.__init__(self, authenticator)
        self.streamManager = StreamManager(self)

    def addHandler(self, handler):
        """
        Add a subprotocol handler to the stream manager.
        """
        self.streamManager.addHandler(handler)

    def removeHandler(self, handler):
        """
        Add a subprotocol handler to the stream manager.
        """
        self.streamManager.removeHandler(handler)