Skip to content

Instantly share code, notes, and snippets.

@bamthomas
Created November 11, 2014 22:20
Show Gist options
  • Save bamthomas/3df508bcfa3daf34cb48 to your computer and use it in GitHub Desktop.
Save bamthomas/3df508bcfa3daf34cb48 to your computer and use it in GitHub Desktop.
Minimum xmpp connexion with twisted
from twisted.internet import reactor
from twisted.python.syslog import startLogging
from twisted.words.protocols.jabber.client import XMPPAuthenticator
from twisted.words.protocols.jabber.jid import JID
from twisted.words.protocols.jabber.xmlstream import XmlStreamFactory
from wokkel.subprotocols import StreamManager, XMPPHandler
startLogging()
factory = XmlStreamFactory(XMPPAuthenticator(JID('user@localhost'), u'pass123'))
manager = StreamManager(factory)
manager.logTraffic=True
class PresenceHandler(XMPPHandler):
def connectionInitialized(self):
self.send('<presence/>')
handler = PresenceHandler()
handler.setHandlerParent(manager)
reactor.connectTCP('localhost', 5222, factory)
reactor.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment