Created
November 11, 2014 22:20
-
-
Save bamthomas/3df508bcfa3daf34cb48 to your computer and use it in GitHub Desktop.
Minimum xmpp connexion with twisted
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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