source: doc/examples/pinger.py @ 251:554782284e08

Last change on this file since 251:554782284e08 was 207:3e9d00891fc4, checked in by Ralph Meijer <ralphm@…>, 4 years ago

imported patch py3-examples.patch

File size: 529 bytes
Line 
1"""
2An XMPP subprotocol handler that acts as an XMPP Ping pinger.
3"""
4
5from wokkel.ping import PingClientProtocol
6
7class Pinger(PingClientProtocol):
8    """
9    I send a ping as soon as I have a connection.
10    """
11
12    def __init__(self, entity, sender=None):
13        self.entity = entity
14        self.sender = sender
15
16    def connectionInitialized(self):
17        def cb(response):
18            print("*** Pong ***")
19
20        print("*** Ping ***")
21        d = self.ping(self.entity, sender=self.sender)
22        d.addCallback(cb)
Note: See TracBrowser for help on using the repository browser.