Example #1
0
    def _failed_auth(self, error):
        """ overwrite in derivated class """
        log.info("Auth failed, trying to autoregister")
        self._factory.authenticator.registerAccount(self._user.split('@')[0], self._password)

        # Initialize again in a few
        reactor.callLater(3, self._factory.authenticator.initializeStream)
Example #2
0
    def _authd(self, xml_stream):
        """
        Authenticated event callback.

        This method gets called when login has been successful.
        """
        log.info("XMPPClient authenticated")

        for message, callable in self._observers:
            self._xs.addObserver(message, callable)

        presence = Element(('jabber:client', 'presence'))
        self._xs.send(presence)
Example #3
0
    def _failed_auth(self, error):
        """ overwrite in derivated class """
        self.failed_count += 1
        log.info("Auth failed, trying to autoregister")

        if self.failed_count > MAX_FAILED_LOGINS:
            log.critical("Too many auth failures")
            reactor.stop()

        self._factory.authenticator.registerAccount(self._user.split('@')[0], self._password)

        # Initialize again in a few
        reactor.callLater(5, self._factory.authenticator.initializeStream)
Example #4
0
    def _authd(self, xml_stream):
        """
        Authenticated event callback.

        This method gets called when login has been successful.
        """
        log.info("XMPPClient authenticated")

        #Keepalive: Send a newline every 60 seconds
        #to avoid server disconnect
        self._keep_alive_lc = LoopingCall(self._xs.send, '\n')
        self._keep_alive_lc.start(60)
        self._xs.addObserver(STREAM_END_EVENT,
                             lambda _: self._keep_alive_lc.stop())

        for message, callable in self._observers:
            self._xs.addObserver(message, callable)

        presence = Element(('jabber:client', 'presence'))
        self._xs.send(presence)
Example #5
0
 def _connected(self, xml_stream):
     log.info("XMPPClient connected")
     self._xs = xml_stream
Example #6
0
 def _stream_end(self, error):
     """ overwrite in derivated class """
     log.info("XMPPClient stream end")