views:

118

answers:

2

Hi,

I am designing a web application using GWT currently, which is also the first time i am using GWT. I just have a general question about how (or can) GWT handles communications between multilpe clients.

My application needs user to login and has personalized pages for different users, GWT is well able to do all of these. The only problem is user needs to know what other users are doing, a simple example is like Google Talk, when one user is "typing", the other side will be noticed. So i am just wondering if GWT can do this?

As i said this is my first time using GWT, so, if GWT is well able to provide the these user interacting functions, i will go with GWT, otherwise i can make changes when it is not too late.

Thanks!!!

+1  A: 

Looking at the example you gave, if user A starts typing, there's no problem sending the "started typing" event to the server. The server would than have to look up who user A is talking with (say, user B), and get the information to B's browser. This is, of course, the trickier part, but there is more than one way to perform the task, as described for instance here.

In summary, if you're OK with passing the requests through the server, I don't see a problem with using GWT as the underlying technology.

Tomislav Nakic-Alfirevic
Great! Thanks!!!!
+1  A: 

What you need is server push/ajax push/comet/many other names. I've summarized the options you have for GWT in a different answer.

For a quick start, check out NGiNX_HTTP_Push_Module - IMHO it's the easiest one to customize to your needs and they provide a nice chat example that should get you started. However, if you also use jQuery or Mootools in your application (for example, for UI effects), you might want to also consider Ajax Push Engine/APE-Project (but remember that jQuery/Mootools might require some tweaking to work with GWT). Those two are my favorites :)

Igor Klimer
Thanks for these links! It is always good to know some new stuffs, thanks!! i am not going to use JQuery or Mootools, actually, the html page in my application has an empty <body></body>, i am trying to implement everything using GWT. Don't know if this is the right, or there is no right/wrong and only advantages/disadvantages, any comments?
About not using jQuery/Mootools - IMHO that's the right call, less/no external dependencies => better/less code to download. Empty `<body>` tag is also OK (I usually just have some divs that define the general layout). **However** remember that your site will appear as such to search engines - that is empty `<body>` and nothing more (ok, `<title>` counts too ;)). Anything you generate with GWT (or more specifically - JavaScript) won't be seen by web crawlers, since they don't understand/parse JavaScript. It's something worth keeping in mind (there are ways to sidestep this limitation though).
Igor Klimer
This is a good point, i am doing these as my college project, and it is going to run on localhost only. However, i will take your suggestions in my future GWT applications. I just have another question. In general, should i separate entry point class into several small classes for composites, or just have a big single entry point class? GWT allows developers to use OO programming language, so developers should take this advantage, However, i found that using separated composites makes designing and updating easier, but it is pain to handle all handlers on separated classes for composites.
You definitely want to take the OO approach - that's one of the strongest points of GWT. However, don't just chop up the application into classes that mix up UI and business logic (it gets messy really quickly and becomes a nightmare to change anything) - I strongly recommend looking into the MVP pattern (Model-View-Presenter). There are many questions here on SO explaining this, even more GWT's Google Group. For starters, watch the presentation that started it all http://code.google.com/events/io/2009/sessions/GoogleWebToolkitBestPractices.html
Igor Klimer