I use the twisted.words.protocols.jabber.client.XMPPClientFactory . Do you know how I can callback a function whe开发者_运维百科n the connection gets lost (for example WiFi-connection is down)?
thank you for your help!
You can either add a bootstrap for xmlstream.STREAM_END_EVENT or set a defer to clientConnectionLost.
from twisted.words.protocols.jabber import client
from twisted.words.protocols.jabber import jid
from twisted.words.protocols.jabber import xmlstream
j = jid.JID("name@example.org/bla")
p = "some pass"
factory = client.XMPPClientFactory(j, p)
bootstrap method
factory.addBootstrap(
xmlstream.STREAM_END_EVENT,
some_fuction,
)
or
defer method
d = defer.Deferred()
factory.clientConnectionLost = d
精彩评论