开发者

Twisted connectionLost Event

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜