disconnect if link seems broken
This commit is contained in:
parent
d1539ac5e1
commit
84f86a589c
1 changed files with 11 additions and 0 deletions
|
@ -213,6 +213,7 @@ class Connection(xmlstream.Client):
|
||||||
self._expected = {}
|
self._expected = {}
|
||||||
|
|
||||||
self._id = 0;
|
self._id = 0;
|
||||||
|
self._lastIncome = time.time()
|
||||||
|
|
||||||
self.lastErr = ''
|
self.lastErr = ''
|
||||||
self.lastErrCode = 0
|
self.lastErrCode = 0
|
||||||
|
@ -257,6 +258,7 @@ class Connection(xmlstream.Client):
|
||||||
"""Called internally when a 'protocol element' is received.
|
"""Called internally when a 'protocol element' is received.
|
||||||
Builds the relevant jabber.py object and dispatches it
|
Builds the relevant jabber.py object and dispatches it
|
||||||
to a relevant function or callback."""
|
to a relevant function or callback."""
|
||||||
|
self.lastIncome = time.time()
|
||||||
name=stanza.getName()
|
name=stanza.getName()
|
||||||
if not self.handlers.has_key(name):
|
if not self.handlers.has_key(name):
|
||||||
self.DEBUG("whats a tag -> " + name,DBG_NODE_UNKNOWN)
|
self.DEBUG("whats a tag -> " + name,DBG_NODE_UNKNOWN)
|
||||||
|
@ -408,6 +410,15 @@ class Connection(xmlstream.Client):
|
||||||
self._id = self._id + 1
|
self._id = self._id + 1
|
||||||
return ustr(self._id)
|
return ustr(self._id)
|
||||||
|
|
||||||
|
def process(self, timeout=0):
|
||||||
|
if time.time() > self._lastIncome + timeout:
|
||||||
|
self._lastIncome = time.time()
|
||||||
|
iq = Iq(type="get", to=self._host, query=NS_LAST)
|
||||||
|
print "iq", iq
|
||||||
|
if not self.SendAndWaitForResponse(iq, timeout=30):
|
||||||
|
self.disconnectHandler(self)
|
||||||
|
return xmlstream.Client.process(self, timeout)
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
class Client(Connection):
|
class Client(Connection):
|
||||||
|
|
Loading…
Add table
Reference in a new issue