RPC call in Activity onStop()

142 views
Skip to first unread message

yves

unread,
Feb 17, 2013, 5:47:12 PM2/17/13
to google-we...@googlegroups.com
Hi,

After a search on the net I didn't find an answer to this problem : I need to make an RPC call from the onStop() function in order to inform the server that the application is closing.

Apprently this doesn't work : the server never gets RPC-called from onStop(). (I checked that onStop is called...)

Thus my questions are :
1) Is it really impossible to make an RPC call during the onStop process ?
2) In case it is impossible, is there any way to know that the app is closing so I can make a last RPC call ?

Thank you for your suggestions.
Yves

yves

unread,
Feb 19, 2013, 5:15:03 PM2/19/13
to google-we...@googlegroups.com
Not any suggestion ?
Thanks
Yves

Jens

unread,
Feb 19, 2013, 5:45:32 PM2/19/13
to google-we...@googlegroups.com
I don't see why it should not work. You can do an RPC request in Activity.onStop() but you have to be aware of the fact that the activity will continue to stop while the request is pending. So your request's callback should not do anything that depends on the activity state or its view (which will be detached after the activity is stopped).

You can also do a RPC request in Window.addClosingHandler() which will be called before the window/tab gets closed. But again in this case the callback is probably never called as the window/tab gets closed while the request is pending. All you could do here is telling the server that the app "terminates" now and let the server invalidate the users session for example.

Have you checked FireBug/Chrome Devtools and verified that no last request is made?

-- J.

K vfdsdfbsdb

unread,
Feb 19, 2013, 5:53:56 PM2/19/13
to google-we...@googlegroups.com

hi.

do you use onStop of Activiti interface?
if you use it, it is call when it's wiget is clised.

2013/02/18 7:47 "yves" <yves....@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

yves

unread,
Feb 21, 2013, 4:06:46 PM2/21/13
to google-we...@googlegroups.com
Sorry for my late reaction.
Indeed I don't need the callback, I just need to send a "terminates" message to the server to release some temporary work data.
As it didn't worked, I removed this part of the code, so I can't give right now an example. But the fact is that the server didn't received the call (checked with a lot of debug logs and breakpoints).
I'll try again, also with the addClosingHandler() which I didn't knew.
Thanks for the suggestion.
I'll come back soon.
Yves

yves

unread,
Feb 21, 2013, 4:14:37 PM2/21/13
to google-we...@googlegroups.com
Actually it is a subclass of AbstractActivity and onStop() is overridden.
The fact the widget is being destroyed (? I am not sure of what really happens at this moment) could be the source of the problem because I have a lot of things to do during the onStop() call and something might go wrong in the client.
Thanks for input.
Yves

Milan Cvejic

unread,
Feb 21, 2013, 4:22:32 PM2/21/13
to google-we...@googlegroups.com
Try to send request in mayStop method. It may work as widget is still not destroyed nor deatached.

yves

unread,
Mar 5, 2013, 2:10:59 PM3/5/13
to google-we...@googlegroups.com
Hi,

Finally I didn't succeed to make an RPC call from the overridden AbstractActivity.onStop().
Actually the GWT doc says about onStop() : "Called when the Activity's widget has been removed from view".
I guess that all the RPC mechanisms is already destroyed because the server never get called.

@Milan : I can't make the call during mayStop because I don't know at that moment whether the user will choose to close or not the activity. The RPC call must be executed only when the activity is effectively stopped.

The only ugly workaround I found is a kind of watchdog between the client and the server so that the client periodically tells to the server "I am still here".


If someone succeeded to make an RPC call during onStop(), I would appreciate the feedback :-)

Yves

Milan Cvejic

unread,
Mar 5, 2013, 2:25:51 PM3/5/13
to google-we...@googlegroups.com
Hey Yves,
maybe you can hook and listen on PlaceChangeEvent. That event actually calls onStop(). So if that event is fired than you can execute your RPC call.

Best,
Milan



Yves

--
You received this message because you are subscribed to a topic in the Google Groups "Google Web Toolkit" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-web-toolkit/qQ3s-u6XEBs/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to google-web-tool...@googlegroups.com.

yves

unread,
Mar 5, 2013, 4:21:37 PM3/5/13
to google-we...@googlegroups.com
The use case is when one is closing the browser or the tab or when navigating to another url, thus really quitting the GWT application, not just changing Place.
I found that apparently in this case the ActivityManager.onPlaceChange(PlaceChangeEvent event) seems to be never called.
And then onStop() is NOT called in my use case.

Yves
Reply all
Reply to author
Forward
0 new messages