views:

55

answers:

3

Hi, I'm looking for a library that will allow me to deliver simple text events from the server to the clients via sockets. Something simple and lightweight. I can write it myself, but decided to check if such thing exists first. The idea is that there's an application that generates events (such as order rejected or an internal error occurred) and acts as a server. Those events must be delivered to all connected clients in real-time. And a client is just a tray-icon app that pop ups the said event's text. Some simple UDP client/server. Does anyone know if there's a library out there for Java?

Thanks!

+1  A: 

You should check out JBoss Netty and/or Apache MINA, which are both frameworks for building network protocols. It's debatable whether you consider them simple, although you can certainly build lightweight implementations with them.

skaffman
+2  A: 

This could be easily accomplished with XMPP pubsub. You can use Smack to connect to the server of your choice that supports pubsub (OpenFire, ejabberd, ...) so your application that creates the events is the publisher and the clients are all subscribers. It will require a 3rd party server to be used (many are open source), but it is just a single library for all client access. I have experience with OpenFire and it can be set up in about 15 minutes.

Many will not consider this light weight, but rolling your own pubsub solution is really not necessary.

Robin
That's an interesting idea. Though not really lightweight especially since I'm not expecting more than 10 clients. But this gives me an idea, maybe I can simply have an IM client that can send messages to others. Any free AIM libraries out there?
Daniil
@Danil - I believe most if not all IM solutions require a server. The server is what keeps track of who is logged in and what users are valid and actually disseminating the messages. XMPP is an IM protocol and the pubsub extension is what I believe best fits your requirement. You could potentially skip the pubsub and use an existing XMPP client (http://xmpp.org/software/clients.shtml) and simply set up a chat room if that is sufficient. No coding required.
Robin
@Robin - yep, a simple AIM client would do a trick. Connect to AIM server and send IMs to preset number of nicks. Something like a AIM bot.
Daniil
+1  A: 

There are many possible solutions, but if you want simple I suggest you try Hazelcast

It is as simple as using java.util.{Queue, Set, List, Map}. Just add the hazelcast.jar into your classpath and start coding.

Peter Lawrey