32 lines
1.3 KiB
Python
32 lines
1.3 KiB
Python
|
#!/usr/bin/python
|
||
|
# -*- coding: utf-8 -*-
|
||
|
|
||
|
from slixmpp import ClientXMPP
|
||
|
|
||
|
class XmppInstance(ClientXMPP):
|
||
|
def __init__(self, jid, password):
|
||
|
super().__init__(jid, password)
|
||
|
#self.add_event_handler("connection_failed", self.on_connection_failed)
|
||
|
#self.add_event_handler("failed_auth", self.on_failed_auth)
|
||
|
self.add_event_handler("session_start", self.on_session_start)
|
||
|
self.register_plugin('xep_0004') # XEP-0004: Data Forms
|
||
|
self.register_plugin('xep_0030') # XEP-0030: Service Discovery
|
||
|
self.register_plugin('xep_0059') # XEP-0059: Result Set Management
|
||
|
self.register_plugin('xep_0060') # XEP-0060: Publish-Subscribe
|
||
|
self.register_plugin('xep_0078') # XEP-0078: Non-SASL Authentication
|
||
|
self.register_plugin('xep_0163') # XEP-0163: Personal Eventing Protocol
|
||
|
self.register_plugin('xep_0223') # XEP-0223: Persistent Storage of Private Data via PubSub
|
||
|
self.connect()
|
||
|
# self.process(forever=False)
|
||
|
|
||
|
self.connection_accepted = False
|
||
|
|
||
|
# def on_connection_failed(self, event):
|
||
|
# self.connection_accepted = False
|
||
|
|
||
|
# def on_failed_auth(self, event):
|
||
|
# self.connection_accepted = False
|
||
|
|
||
|
def on_session_start(self, event):
|
||
|
self.connection_accepted = True
|