문제

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?

도움이 되었습니까?

해결책

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 :)

다른 팁

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)

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top