1

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?

Michael Bates
  • 1,884
  • 2
  • 29
  • 40

2 Answers2

2

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.

Abhinav Singh
  • 2,643
  • 1
  • 19
  • 29
  • Thanks for your comment, I believe you're the one who wrote JAXL? This looks very promising from my initial research, I will definitely be looking at implementing this. – Michael Bates Jul 23 '12 at 10:25
  • Is JAXL 3.x more object oriented? That was the other problem I had - it seemed like it was written for PHP 4. – Michael Bates Jul 23 '12 at 10:28
  • yes directly from the docs i will quote "Inside Jaxl everything that you will interact with will be an object which will emit events and callbacks which we will be able to catch in our applications for custom processing and routing" - http://jaxl.readthedocs.org/en/latest/users/getting_started.html#library-structure – Abhinav Singh Jul 23 '12 at 13:16
1

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.

Michael Bates
  • 1,884
  • 2
  • 29
  • 40