views:

119

answers:

4

Hello Guys

I am creating a website where users will be able to chat and send files to one another through a browser. I am using GWT for the UI and hibernate with gilead to connect to a mysql database backend.

What would be the best strategy to use so Users can interact together?

A: 

inigrate facebook? or add a forum? there isn't really a limit as to what you can do.

WalterJ89
I was thinking in terms of the communication(programming) aspect of using gwt so users can talk to each other and see who is online and who is not
molleman
+2  A: 

I'd say you are looking for comet/AJAX|Server push/etc. See my previous answer on this matter for some pointers. Basically you are simulating inverting the communication between server and client - it's the server that's initiating the connection here, since it wants to, for example, inform the user that his/her friend just went online, etc.

The implementations of this technique change quite rapidly, so I won't make any definitive recommendations - choose the one that best suits your needs :)

Igor Klimer
+2  A: 

COMET is the technology that allows chatting over a web page - It is basically communicating through keep-alive connections. This allows servers to push information to the client. There are several implementations of this on the client side with GWT. Most servers nowadays support this, It is also part of the Servlet 3.0 spec (Which nobody has implemented yet)

Romain Hippeau
@Romain: Servlet 3.0 is already implemented e.g. by Glassfish v3 release.
Chris Lercher
+1  A: 

While COMET is very nice, it's not the only solution! Usual polling with time intervals (as opposed to COMET long polling) is still commonly used. It's also possible to require a manual refresh by the user.

Take Stackoverflow as an example - for most things you must refresh your browser manually to see the changes. I think, it's commonly perceived as normal and expected. COMET or frequent polling are an added bonus.

The problem with COMET is, that it can easily lead to lots of threads on the server. Except, if you additionally use asynchronous processing (also called "Advanced IO"), which is not too well supported yet (e.g. doesn't work with HTTPS in Glassfish v3 due to a severe bug), can lead to problems with Apache connectors etc.

The problem with frequent polling is, that it creates additional traffic. So, it's often necessary to make the polling less frequent, which will make it less convenient for the end user.

So you will have to weigh the options for your particular situation.

Chris Lercher
Igor Klimer
@Igor: I agree about the servers - it's just, that some people have no other choice than using Apache! With full refresh, I don't necessarily mean a full page refresh. It can also be a click on an update link/button that results in an Ajax call. And the question, what creates more strain on the server, Comet or constant polling, depends on several factors: If the messages arrive in an extremely fast pace, or if they're distributed quite evenly, then the COMET advantage is small - but since COMET is stateful, you always have the overhead of remembering its state. It really depends!
Chris Lercher