如何在本地机器上测试xmpp/jabber?
我刚刚开始阅读 Oreilly 的 XMPP 权威指南,对于 hello world,他们有这个脚本:
def main():
bot = EchoBot("[email protected]/HelloWorld", "mypass")
bot.run()
class EchoBot(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"])
但它没有说明如何在我的本地计算机上测试和运行它。我对 xmpp 真的很陌生,有点困惑。我是否设置本地 xmpp 服务器,或者是否有一个现有的服务器可供我测试?
I just started reading Oreilly's XMPP The Definitive Guide and for the hello world, they have this script:
def main():
bot = EchoBot("[email protected]/HelloWorld", "mypass")
bot.run()
class EchoBot(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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,如果您想在本地进行测试,您可能需要安装自己的服务器。许多服务器都有一键式安装系统,可以轻松地在您的平台上进行安装。
如果您在 Google Chat(即 XMPP)等平台上或 jabber.org 等任何其他平台上有一个托管 XMPP 帐户,它也应该与托管 XMPP 帐户一起使用。
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.