Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » ServerPushSessions(Running a session as long as ui session is active?)
ServerPushSessions [message #1065105] Mon, 24 June 2013 11:40 Go to next message
Sebastian Habenicht is currently offline Sebastian Habenicht
Messages: 10
Registered: January 2013
Junior Member
Hi,

I implemented a simple short message functionality: Type in a short message and send it to another user. The message is shown on the other user's display immediately. I use ServerPushSessions in this approach:


  • when user logs into application the ui session's display is registered in a static context
  • a ServerPushSession is started right away
  • when another user sends a message, asyncExec is invoked on the registered receiver's display to show the message
  • whenui session is destroyed the ServerPushSession is stopped and the display is removed


I wonder if this is what ServerPushSessions have been designed for. I think that probably polling might be more suitable for this functionality, but I found the ServerPushSession approach interesting.

I use ServerPushSessions in background threads to e.g. hide a "Processing your request..." label when the background thread is done - which is afaik a classic use case for ServerPushSessions. When the above mentioned short message functionality is running, other ServerPushSessions are superfluous because there will always be a running ServerPushSession as long as the ui session is active.

So my questions are:

1. Might technical issues arise when every ui session has an active ServerPushSession while it is alive (because the documenation says to stop unused ServerPushSessions in order to free resources related to it)?
2. Would such an implementation lead to a constant loading symbol on mobile devices (as mentioned here: http://www.eclipse.org/forums/index.php/mv/msg/452311/1007319/#msg_1007319)?
3. Any other disadvantages?

Thanks for any thoughts on this.

Regards,
Sebastian














[Updated on: Mon, 24 June 2013 11:43]

Report message to a moderator

Re: ServerPushSessions [message #1065277 is a reply to message #1065105] Tue, 25 June 2013 08:21 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf Sternberg
Messages: 1290
Registered: July 2009
Senior Member

Hi Sebastian,

The ApplicationContext is a better place to store the reference to
another user's Display - static means system-wide, i.e. across the VM,
which is more than you need. Moreover, you should think about thread
safety and double check that the reference is cleaned up correctly to
avoid a memory leak.

In contrast to polling, the long-polling approach guarantees an
immediate feedback and spares traffic when there are few updates.

For applications that expect messages at any time, there's no
alternative to starting a global ServerPushSession and keeping it alive.
An active server push leads to a permanent standing request which may
block resources on the server, such as a thread from the servlet
container's thread pool. Whether this is problem probably depends on
your servlet container and maybe network infrastructure. I *think* it
might be problematic for a big number of users, but I've never heard any
complaints so far.

A ServerPush should not lead to a loading icon on mobile devices.

Regards,
Ralf

--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: ServerPushSessions [message #1066166 is a reply to message #1065277] Mon, 01 July 2013 10:27 Go to previous messageGo to next message
Sebastian Habenicht is currently offline Sebastian Habenicht
Messages: 10
Registered: January 2013
Junior Member
Hi Ralf,

thanks for your answer. I will keep it in mind while refactoring the functionality.

Regards,
Sebastian
Re: ServerPushSessions [message #1220855 is a reply to message #1065105] Sat, 14 December 2013 13:22 Go to previous messageGo to next message
David Lee is currently offline David Lee
Messages: 24
Registered: May 2013
Junior Member
Hi, Sebastian Habenicht,

I succeeded showing a MessageBox on a specified user's display from another's(session)!
I am trying to implement a function that show specific messages on another user's UI control like a multi-line Text instead of a MessageBox, but I cannot access another user's UI, it always says "invalid thread"!
In other words, how to update another UI? could you or anyone please let me know how to solve it?

Any response would be greatly appreciated.

[Updated on: Sat, 14 December 2013 13:48]

Report message to a moderator

Re: ServerPushSessions [message #1221272 is a reply to message #1220855] Tue, 17 December 2013 09:23 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf Sternberg
Messages: 1290
Registered: July 2009
Senior Member

Hi David,

UI elements can only be accessed from the UI thread. Every UI session
has its own UI thread. To access another user's widgets, you have to
wrap your code in a runnable and let the respective display's asyncExec
method call it. You can find an example in the developer's guide article
on server push [1].

HTH, Ralf


[1]
http://eclipse.org/rap/developers-guide/devguide.php?topic=server-push.html&version=2.2

--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: ServerPushSessions [message #1221976 is a reply to message #1221272] Thu, 19 December 2013 05:05 Go to previous message
David Lee is currently offline David Lee
Messages: 24
Registered: May 2013
Junior Member
Hi, Ralf,

Thank you for your reply!
I tried the sample before, but always got "Invalid thread access", still cannot refresh any other online user's UI control(on another computer) except showing a messagebox by display.asyncExec, due to being busy these days, I'll try it again based on your guide few days later! Thanks again!
Previous Topic:Cannot cast from a.Class to a.Class
Next Topic:[ANN] RAP 2.2 released
Goto Forum:
  


Current Time: Fri Sep 19 06:11:13 GMT 2014

Powered by FUDForum. Page generated in 0.01950 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software