Synchronization on the server depends on the resources you want to protect 
access to. Synchronizing 
a method in RemoteServiceSerlvet is a /very/ bad idea, since it ensures that 
only one user can use 
that method at a time.

You also can't assume that if you take up one of the browsers connections that 
there will only be 
one left, rather you should assume you have only 2 connections to deal with, 
but don't rely on it 
for any code logic (since some browsers may allow more).

The code you posted doesn't ensure that one connection will always be taken by 
getEvents, although 
single-threaded, that code is subject to a standard race-condition with regards 
to the browser 
Connections. Other code attempting a server connection may e given the 
opportunity to grab the 
connection after one call to getEvents() returns and before onSuccess() is 
called.

To run a comet style process (or a timed comet process) you would rather start 
the next comet 
request in the onSuccess /and/ onFailure methods of the AsyncCallback. If you 
need to wait a 
specified delay before sending the next requests, use a Timer.

I would also recommend looking over:
http://code.google.com/docreader/#p=google-web-toolkit-doc-1-5&s=google-web-toolkit-doc-1-5&t=ReleaseNotes_1_5_Rpc
Returning the Request object so that an exiting comet request can be canceled 
if you need to send 
more data.

Not quite sure exactly what you're looking for, if I'm on the wrong track let 
me know.
Hope this is helping.
//J

ralph wrote:
> 
> In that case does that mean that I should synchronize on the server
> side? And what about if I have one connection that it is continuously
> recycled, does that mean that having only one connection left I can
> confidently say that the logic is synchronous on the server side?
> 
> And does this code below ensure that the connection will always be
> taken by getEvents.
> 
> getEvents(new AsyncCallback() {
> 
> onSuccess() {
>    getEvents(this);
> }
> 
> }
> 
> Thanks
> > 
> 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to