Why Openfire?

(With my both hands up).

After much research I have found that Openfire is apparently a good tool to write chat applications against using smack library. I don’t think I understand why we use openfire (for my purpose anway).

My application will (hopefully) have some users registered. I would like them to be able to send messages to each other (chat experience would be great). From the spike I’ve done, I can create users in OF and send message to another user who is also registered to the OF server (verfied by using Spark client). The message sent back using the Spark client is received by my ChatMessage listener. All good so far.

But this perhaps where I am a bit lost. The message I received from the user using Spark client now needs to be sent down to my client (which I believe I will either need to push or the client pulls). I could very easily store each message sent by the users in a DB and get the client to request for messages sent to them. If I am to doing this, I don’t see why I would use openfire.

Can anyone pls explain how openfire is supposed to be used.

AD

That depends on the type of application you are wrting. Is it web based or standalone. Smack a good choice for a standalone app and once you create a connection to the XMPP server (Openfire), you will already have the ability to both send and receive messages. You don’t have to do anything explicit to pull the messages, XMPP connections are bidirectional and real time.

Its a standalone app which talks to a tomcat server which in turn talks to the openfire server using an XmppConnection. So, should the client be making an Xmppconnection to the openfire server? If yes, what would be a good design in terms of making sure the client is not doing the heavy work?

I don’t know much about your app, so it is hard to comment on how you should design it. But since you said you want to send chat messages from the client, I don’t see why you would want to use Tomcat as an intermediary. It would be much simpler to use XMPP directly from your client, as XMPP maintains long lived connections.