mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-30 19:19:55 +00:00
Simplify boilerplate example.
This commit is contained in:
parent
5d7111fe3b
commit
9faecec2db
1 changed files with 13 additions and 16 deletions
27
README.rst
27
README.rst
|
@ -112,13 +112,21 @@ SleekXMPP projects::
|
||||||
def __init__(self, jid, password):
|
def __init__(self, jid, password):
|
||||||
ClientXMPP.__init__(self, jid, password)
|
ClientXMPP.__init__(self, jid, password)
|
||||||
|
|
||||||
self.add_event_handler("session_start", self.start)
|
self.add_event_handler("session_start", self.session_start)
|
||||||
self.add_event_handler("message", self.message)
|
self.add_event_handler("message", self.message)
|
||||||
|
|
||||||
def start(self, event):
|
self.register_plugin('xep_0030') # Service Discovery
|
||||||
|
self.register_plugin('xep_0199') # XMPP Ping
|
||||||
|
|
||||||
|
# If you are working with an OpenFire server, you will
|
||||||
|
# need to use a different SSL version:
|
||||||
|
# import ssl
|
||||||
|
# self.ssl_version = ssl.PROTOCOL_SSLv3
|
||||||
|
|
||||||
|
def session_start(self, event):
|
||||||
self.send_presence()
|
self.send_presence()
|
||||||
|
|
||||||
# Most get_* methods from plugins use Iq stanzas, which
|
# Most get_*/set_* methods from plugins use Iq stanzas, which
|
||||||
# can generate IqError and IqTimeout exceptions
|
# can generate IqError and IqTimeout exceptions
|
||||||
try:
|
try:
|
||||||
self.get_roster()
|
self.get_roster()
|
||||||
|
@ -143,19 +151,8 @@ SleekXMPP projects::
|
||||||
format='%(levelname)-8s %(message)s')
|
format='%(levelname)-8s %(message)s')
|
||||||
|
|
||||||
xmpp = EchoBot('somejid@example.com', 'use_getpass')
|
xmpp = EchoBot('somejid@example.com', 'use_getpass')
|
||||||
xmpp.register_plugin('xep_0030') # Service Discovery
|
xmpp.connect():
|
||||||
xmpp.register_plugin('xep_0199') # XMPP Ping
|
|
||||||
|
|
||||||
# If you are working with an OpenFire server, you will need
|
|
||||||
# to use a different SSL version:
|
|
||||||
#
|
|
||||||
# import ssl
|
|
||||||
# xmpp.ssl_version = ssl.PROTOCOL_SSLv3
|
|
||||||
|
|
||||||
if xmpp.connect():
|
|
||||||
xmpp.process(block=True)
|
xmpp.process(block=True)
|
||||||
else:
|
|
||||||
print("Unable to connect.")
|
|
||||||
|
|
||||||
|
|
||||||
Credits
|
Credits
|
||||||
|
|
Loading…
Reference in a new issue