Server push using Polling [message #778561] |
Fri, 13 January 2012 04:55  |
Eclipse User |
|
|
|
Hi,
In my RAP application I'm trying to detect browser close events using the Polling mechanism i.e injecting a client side js to regularly send requests to the server. On the server I have code to keep track of these requests, and once these requests stop coming, I know that the browser has been closed.
The client side js that I inject is
String code = "window.setInterval( function() {\n"
+ " org.eclipse.swt.Request.getInstance().send();\n"
+ "}, 10000 );"; // polling interval in ms
JSExecutor.executeJS( code );
Now I have 2 issues with this :
1. When I have a user request that takes more time than the interval I have set for the polling request from the client, this logic fails.
So for example if I set the interval to say 40 seconds and I have a request that is taking 60 seconds, then because the client has not sent any request during these 60 seconds, my session termination code is executed.
Looking at the Request.js I see that the maximum capacity for the request queue is set to 1. Hence when one request is under process, no other request can be made from the client.
2. If the browser for some reason hangs for more than 40 seconds the logic fails for the same reason again.
How do I solve this?
|
|
|
|
|
|
|
Re: Server push using Polling [message #779571 is a reply to message #778613] |
Sun, 15 January 2012 23:10  |
Eclipse User |
|
|
|
The way I did it was to provide a little clock in the status bar. Its updated once per minute and because we needed global UICallback's for another purpose it works quite well. Session timeouts are set very short (eg: 5 minutes) and are kept alive by the UICallback. That said you should be running all large operations in a background thread, even more so for an RCP application. Have a look at the jobs API. It works pretty well. There is also the ProgressMonitorDialog.
|
|
|
Powered by
FUDForum. Page generated in 0.27152 seconds