Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ccae4c8

Browse files
author
Ben Weaver
committed
Add timeout API to Plugin.
1 parent c2dc252 commit ccae4c8

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

xmpp/core.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,14 @@ def on_stream_bound(self, bindings):
7474
self.authJID = bindings.jid
7575
self.resources = bindings.resources
7676

77-
def timeout(self, delay, callback):
77+
def add_timeout(self, delay, callback):
7878
self.stream.io.add_timeout(time.time() + delay, callback)
7979
return self
8080

81+
def remove_timeout(self, callback):
82+
self.stream.io.remove_timeout(callback)
83+
return self
84+
8185
### ---------- Incoming Stream ----------
8286

8387
## These are callbacks for the XMPPStream.

xmpp/plugin.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,14 @@ def close(self):
509509
self.__core.close()
510510
return None
511511

512+
def add_timeout(self, *args):
513+
self.__core.add_timeout(*args)
514+
return self
515+
516+
def clear_timeout(self, *args):
517+
self.__core.remove_timeout(*args)
518+
return self
519+
512520
## ---------- Low-level Stream ----------
513521

514522
def open_stream(self, *args):

0 commit comments

Comments
 (0)