【发布时间】:2022-01-23 11:15:09
【问题描述】:
我在 python 中使用 ejabberd,我找到了一种发送消息的方法,但是如何在我的 python 控制台中获取消息或接收这些消息,请建议我一些方法或方法来做到这一点。
发送消息我的代码是
import xmlrpc.client as xmlrpclib
server_url = 'http://127.0.0.1:5180/xmlrpc/'
server = xmlrpclib.ServerProxy(server_url)
EJABBERD_XMLRPC_LOGIN = {'user':'yatish', 'server':'localhost', 'password':'1234', 'admin':False}
def ejabberdctl(command, data):
fn = getattr(server, command)
print(fn.__dict__,'>>>>>>>>>>')
return fn(EJABBERD_XMLRPC_LOGIN, data)
result = ejabberdctl('send_message', {"type":"chat","from":"yatish@localhost","to":"1@localhost",
"subject":"backend subject","body":"Hey this is message from python1"})
在这里我可以从 yatish@localhost 向 1@localhost 用户发送消息无法在 python 中接收所有这些消息。如果收到的消息客户端应该连接并接收消息relatime。
谢谢
【问题讨论】:
标签: python xmpp ejabberd xml-rpc