What would be the best way to create a JS chat client with GWT? The bit that I'm having trouble with is the persistence and transfer of the messages. Should I store the messages in a DB and check the db for new messages? Is there a much better way to do this?
+1
A:
You could either have connected clients continuously poll the server for new messages or you could have a look at Server Push: http://code.google.com/p/google-web-toolkit-incubator/wiki/ServerPushFAQ
jah
2010-03-16 21:23:40
Thanks.Should I use a DB?
Matt H
2010-03-16 21:27:38
No, there wouldn't be any need - unless you want to keep some kind of chat history on the server.
jah
2010-03-16 21:30:01
Sorry, I am confused (new to GWT, too). Should I just use a standard data structure then to store the messages?
Matt H
2010-03-16 21:31:28
Yes. Have a look at the NewMessageEvent class from a GWT chat application:http://code.google.com/p/gwt-eclipsecon-chat/source/browse/trunk/src/org/eclipsecon/gwt/chattr/client/
jah
2010-03-16 22:02:37
+1
A:
Like jah suggested, you definitely want to use Comet/Server Push/Reverse AJAX/many other names. I've compiled your options for GWT in another post.
If you want a quick start, look at the NGiNX_HTTP_Push_Module - they have an easy to understand chat example. You'll have to write some handling of the protocol yourself, but it's a rather simple task.
If you're using Java too on the backend, the easier solution will be rocket-gwt or cometd.
Igor Klimer
2010-03-16 21:31:08
Thanks! I'll look into this - Server Push/whatever looks perfect for what I'm trying to accomplish.One more thing though, if you're still here: How should I store the messages on the server between them being sent and received?
Matt H
2010-03-16 21:39:56
Like jah suggested - use a simple class, probably only with getters and setters, for that. You might also want to look into JavaScript Overlay Objects for much easier handling of JSON responses from the server: http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsOverlay.html
Igor Klimer
2010-03-16 22:54:35
If you are using Google App Engine then my guess is rocket-gwt is the way to go - APE and nginx push module both require specialized servers, which AFAIK are not available on GAE. On the other hand, rocket-gwt should integrate pretty nicely - but I don't have much experience with GAE myself, so it's just a guess :)
Igor Klimer
2010-03-20 23:32:19