用于发送和接收消息的 JAXL XMPP 守护进程
我用 PHP (Debian 6.0) 编写了一个 JAXL 守护进程,它负责监听传入的消息,然后通过将有效负载传递给 API 来处理传入的消息。 (侦听 user1@server 上的传入消息)
我遇到的麻烦是将消息发送回用户。我现在的做法是启动另一个 XMPP 守护进程,发送消息,然后关闭该守护进程。这样做的问题是它正在启动另一个带有 JID user1@server 的守护进程来发送到 user2@server。当我关闭 JAXL 时,它也会关闭“监听”守护进程。
我考虑在发送消息时再次启动监听守护进程,但启动时间太长(1-2 秒),而且我的应用程序无法真正承受该等待时间。
有谁知道如何解决这个问题,也许还可以使用监听守护进程发送消息?
I have written a JAXL daemon in PHP (Debian 6.0) which sits and listens for messages coming in and then process the incoming message by passing the payload to an API. (listens for incoming messages on user1@server)
The trouble I am having is then sending a message back to the user. The way I have done it now is I start another XMPP daemon, send the message, then shutdown the daemon. The trouble with this is that it is starting another daemon with the JID user1@server to send to user2@server. When I shutdown JAXL it also shuts down the 'listening' daemon.
I considered starting the listening daemon again when I send the message but that takes too long to start (1-2 seconds) and my app can't really afford that wait time.
Does anyone have any ideas how I could solve this, perhaps by using the listening daemon to send messages as well?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
很高兴听到这一进展。虽然从您的示例代码
$jaxl->sendMessage()
看来您正在使用 JAXL v2.x。如果您没有任何硬编码依赖项,我强烈建议您升级到 JAXL v3.x在 v2.x 上。您可以关注此 Google 群组主题通过现有的活动连接发送消息如果您正在考虑使用 v3.x,它现在有一种通过与后台运行的 xmpp 守护进程 (IPC) 通信来发送 xmpp 有效负载的官方方法。您甚至可以使用 v3.x 远程控制您的 xmpp 守护进程以及更多功能。
So nice to hear that progress. Though from your example code
$jaxl->sendMessage()
it seems like you are using JAXL v2.x. I would seriously recommend you to upgrade to JAXL v3.x if you don't have any hard coded dependency upon v2.x.You can follow this google group thread Send a message via an existing active connection if you are considering using v3.x which now have a official way of sending xmpp payload by communicating with an xmpp daemon running in the background (IPC). You can even remotely control your xmpp daemons and a lot more with v3.x.
对于对此感兴趣的任何人,我最终编辑了 JAXL 以在守护程序运行时侦听 UDP 套接字,如果在该 UDP 套接字上收到数据,则使用 $jaxl->sendMessage(...) 和发送消息。然后我编写了一个简单的函数,每当我想发送消息时,它都会将数据发送到这个 UDP 套接字。
Just for anyone who is interested in this, I ended up editing JAXL to listen on a UDP socket while the daemon is running, and if data is recieved on that UDP socket is then uses $jaxl->sendMessage(...) and send a message. I then wrote a simple function which sends data to this UDP socket whenever I want to send a message.