diff options
Diffstat (limited to 'slixmpp')
-rw-r--r-- | slixmpp/basexmpp.py | 4 | ||||
-rw-r--r-- | slixmpp/xmlstream/xmlstream.py | 14 |
2 files changed, 18 insertions, 0 deletions
diff --git a/slixmpp/basexmpp.py b/slixmpp/basexmpp.py index b15354c9..a3aa557a 100644 --- a/slixmpp/basexmpp.py +++ b/slixmpp/basexmpp.py @@ -203,6 +203,10 @@ class BaseXMPP(XMLStream): log.warning('Legacy XMPP 0.9 protocol detected.') self.event('legacy_protocol') + def process(self, timeout=None): + self.init_plugins() + XMLStream.process(self, timeout) + def init_plugins(self): for name in self.plugin: if not hasattr(self.plugin[name], 'post_inited'): diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py index e3a8265a..ff5a3d26 100644 --- a/slixmpp/xmlstream/xmlstream.py +++ b/slixmpp/xmlstream/xmlstream.py @@ -302,6 +302,20 @@ class XMLStream(object): except OSError as e: self.event("connection_failed", e) + def process(self, timeout=None): + """Process all the available XMPP events (receiving or sending data on the + socket(s), calling various registered callbacks, calling expired + timers, handling signal events, etc). If timeout is None, this + function will run forever. If timeout is a number, this function + will return after the given time in seconds. + """ + loop = asyncio.get_event_loop() + if timeout is None: + loop.run_forever() + else: + future = asyncio.sleep(timeout) + loop.run_until_complete(future) + def init_parser(self): """init the XML parser. The parser must always be reset for each new connexion |