File: pinger.py

package info (click to toggle)
wokkel 18.0.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,352 kB
  • sloc: python: 11,753; makefile: 6
file content (22 lines) | stat: -rw-r--r-- 529 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""
An XMPP subprotocol handler that acts as an XMPP Ping pinger.
"""

from wokkel.ping import PingClientProtocol

class Pinger(PingClientProtocol):
    """
    I send a ping as soon as I have a connection.
    """

    def __init__(self, entity, sender=None):
        self.entity = entity
        self.sender = sender

    def connectionInitialized(self):
        def cb(response):
            print("*** Pong ***")

        print("*** Ping ***")
        d = self.ping(self.entity, sender=self.sender)
        d.addCallback(cb)