Question

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?

Was it helpful?

Solution 2

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top