Exemple #1
0
    def remove_interest(self, namespace, jid=None):
        """
        Mark an interest in a PEP subscription by including a disco
        feature with the '+notify' extension.

        Arguments:
            namespace -- The base namespace to remove as an interest, such
                         as 'http://jabber.org/protocol/tune'. This may also
                         be a list of such namespaces.
            jid       -- Optionally specify the JID.
        """
        if not isinstance(namespace, (set, list)):
            namespace = [namespace]

        for ns in namespace:
            self.xmpp['xep_0030'].del_feature(jid=jid,
                                              feature='%s+notify' % namespace)
        asyncio.ensure_future(self.xmpp['xep_0115'].update_caps(jid))
Exemple #2
0
    def add_interest(self, namespace: str, jid: Optional[JID] = None):
        """
        Mark an interest in a PEP subscription by including a disco
        feature with the '+notify' extension.

        :param namespace: The base namespace to register as an interest, such
                          as 'http://jabber.org/protocol/tune'. This may also
                          be a list of such namespaces.
        :param jid: Optionally specify the JID.
        """
        if not isinstance(namespace, set) and not isinstance(namespace, list):
            namespace = [namespace]

        for ns in namespace:
            self.xmpp['xep_0030'].add_feature('%s+notify' % ns, jid=jid)
        asyncio.ensure_future(
            self.xmpp['xep_0115'].update_caps(jid),
            loop=self.xmpp.loop,
        )
Exemple #3
0
    def remove_interest(self, namespace, jid=None):
        """
        Mark an interest in a PEP subscription by including a disco
        feature with the '+notify' extension.

        Arguments:
            namespace -- The base namespace to remove as an interest, such
                         as 'http://jabber.org/protocol/tune'. This may also
                         be a list of such namespaces.
            jid       -- Optionally specify the JID.
        """
        if not isinstance(namespace, (set, list)):
            namespace = [namespace]

        for ns in namespace:
            self.xmpp['xep_0030'].del_feature(jid=jid,
                                              feature='%s+notify' % namespace)
        asyncio.ensure_future(
            self.xmpp['xep_0115'].update_caps(jid),
            loop=self.xmpp.loop,
        )
Exemple #4
0
    def enable_keepalive(self, interval=None, timeout=None):
        if interval:
            self.interval = interval
        if timeout:
            self.timeout = timeout

        self.keepalive = True
        handler = lambda event=None: asyncio.ensure_future(self._keepalive(event))
        self.xmpp.schedule('Ping keepalive',
                           self.interval,
                           handler,
                           repeat=True)
Exemple #5
0
    def enable_keepalive(self, interval=None, timeout=None):
        if interval:
            self.interval = interval
        if timeout:
            self.timeout = timeout

        self.keepalive = True
        handler = lambda event=None: asyncio.ensure_future(
            self._keepalive(event))
        self.xmpp.schedule('Ping keepalive',
                           self.interval,
                           handler,
                           repeat=True)
Exemple #6
0
        def handler(event=None):
            # Cleanup futures
            if self.__pending_futures:
                tmp_futures = []
                for future in self.__pending_futures[:]:
                    if not future.done():
                        tmp_futures.append(future)
                self.__pending_futures = tmp_futures

            future = asyncio.ensure_future(
                self._keepalive(event),
                loop=self.xmpp.loop,
            )
            self.__pending_futures.append(future)