| 1 |
""" |
| 2 |
An XMPP subprotocol handler that acts as an XMPP Ping pinger. |
| 3 |
""" |
| 4 |
|
| 5 |
from tx_xmpp.ping import PingClientProtocol |
| 6 |
|
| 7 |
|
| 8 |
class Pinger(PingClientProtocol): |
| 9 |
""" |
| 10 |
I send a ping as soon as I have a connection. |
| 11 |
""" |
| 12 |
|
| 13 |
def __init__(self, entity, sender=None): |
| 14 |
self.entity = entity |
| 15 |
self.sender = sender |
| 16 |
|
| 17 |
def connectionInitialized(self): |
| 18 |
def cb(response): |
| 19 |
print("*** Pong ***") |
| 20 |
|
| 21 |
print("*** Ping ***") |
| 22 |
d = self.ping(self.entity, sender=self.sender) |
| 23 |
d.addCallback(cb) |