gautamaino / gwteventservice

Automatically exported from code.google.com/p/gwteventservice
Other
0 stars 0 forks source link

First event always lost #56

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Call method (e.g. start) on service
2. Call addEvent in that method

What is the expected output? What do you see instead?
Event is not always received in the client.

What version of the product are you using? On what operating system?
1.2.1, Windows 7

Please provide any additional information below.
This problem is also present in the HelloGWTEventService demo. The server sends 
the first event immediately, but this is not always received by the client. The 
first event that is received is the second event (5 seconds later).

Original issue reported on code.google.com by jvz...@gmail.com on 5 Feb 2013 at 1:32

GoogleCodeExporter commented 8 years ago
I think what you see is a race condition which can not be handled by the 
framework.

Where/when do you add the listener? The "problem" is, that the server is 
already sending events before the listener is registered at the server side. 
That could be a normal case, when the server is already running and a new 
client accesses the page.

When you are starting the event execution logic along with the listener 
registration and when you have to ensure that all these events are received 
directly, then the application has to ensure that the listener is registered 
before the events get sent. That can be done by using the optional callback 
parameter of RemoteEventService#addListener(...). The server logic which sends 
events shouldn't start before the onSuccess method of the callback is called.

I have attached a patch for HelloGWTEventService which "fixes" the problem, but 
in that case it isn't important that all events get received (a new client will 
also not get all previous executed events since the server start).

I understand that this behavior isn't self-explanatory and the hint in chapter 
3.3 of the manual isn't sufficient. Therefore I will take this task to extend 
the manual and the FAQs for this case.

Please let me know if the usage of the callback parameter solved the problem.

Original comment by sven.strohschein@googlemail.com on 5 Feb 2013 at 7:00

Attachments:

GoogleCodeExporter commented 8 years ago
Yes, using a callback parameter in the addListener method solved the problem.

Thanks!

Original comment by jvz...@gmail.com on 6 Feb 2013 at 8:45