whitespace ping to avoid disconnection (was disconnected after 6 min of inactivity with openfire)
This commit is contained in:
parent
a9f838a6f2
commit
10b195a345
1 changed files with 7 additions and 2 deletions
9
sat.tac
9
sat.tac
|
|
@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
|
||||
from twisted.application import internet, service
|
||||
from twisted.internet import glib2reactor, protocol
|
||||
from twisted.internet import glib2reactor, protocol, task
|
||||
glib2reactor.install()
|
||||
|
||||
from twisted.words.protocols.jabber import client, jid, xmlstream, error
|
||||
|
|
@ -155,11 +155,16 @@ class SAT:
|
|||
xmlstream.addObserver('/presence', self.presenceCb)
|
||||
xmlstream.addObserver("/iq[@type='set' or @type='get']", self.iqCb)
|
||||
print "********** CONNECTED **********"
|
||||
self.connected=True
|
||||
self.connected=True
|
||||
self.keep_alife = task.LoopingCall(self.xmlstream.send, " ") #Needed to avoid disconnection (specially with openfire)
|
||||
self.keep_alife.start(180)
|
||||
|
||||
#reactor.callLater(2,self.sendFile,"goffi2@jabber.goffi.int/Psi", "/tmp/fakefile")
|
||||
|
||||
def connectionLost(self, connector, unused_reason):
|
||||
print "********** DISCONNECTED **********"
|
||||
if self.keep_alife:
|
||||
self.keep_alife.stop()
|
||||
self.connected=False
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue