2010-02-23 4 views
1

J'utilise twisted.words.protocols.jabber.client.XMPPClientFactory. Savez-vous comment je peux rappeler une fonction lorsque la connexion est perdue (par exemple, la connexion WiFi est en panne)?Twisted connectionLost Événement

je vous remercie pour votre aide!

Répondre

1

Vous pouvez ajouter un bootstrap pour xmlstream.STREAM_END_EVENT ou définir un renvoi à 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("[email protected]/bla") 
p = "some pass" 

factory = client.XMPPClientFactory(j, p) 

méthode bootstrap

factory.addBootstrap(
    xmlstream.STREAM_END_EVENT, 
    some_fuction, 
) 

ou

procédé defer

d = defer.Deferred() 
factory.clientConnectionLost = d