开发者

How to test xmpp/jabber on local machine?

I just started reading Oreilly's XMPP The Definitive Guide and for the hello world, they have this script:

def main():
    bot = EchoBot("echobot@wonderland.lit/HelloWorld", "mypass")
    bot.run()

class Echo开发者_StackOverflow社区Bot(object):
    def __init__(self, jid, password):
        self.xmpp = sleekxmpp.ClientXMPP(jid, password)
        self.xmpp.add_event_handler("session_start", self.handleXMPPConnected)
        self.xmpp.add_event_handler("message", self.handleIncomingMessage)

    def run(self):
        self.xmpp.connect()
        self.xmpp.process(threaded=False)

    def handleXMPPConnected(self, event):
        self.xmpp.sendPresence(pstatus="Send me a message")

    def handleIncomingMessage(self, message):
        self.xmpp.sendMessage(message["jid"], message["message"])

But it didn't say how to test and run this on my local machine. I'm really new to xmpp and a bit confused. Do I setup a local xmpp server or is there an existing one sitting around where I can test this?


Yes, you probably need to install your own server if you want to test it locally. Many servers have a one-click install system that should make it easy to install on your platform.

It should also work with an hosted XMPP account if you have one on a platform like Google Chat (which is XMPP), or any other on platforms like jabber.org.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜