GWT - how a client can detect that it is not synchronized if the server is updated

I have a GWT application where users save the unlimited side of a browser based application. Each time we update the application - if users click on restart in their browsers, then everything will be fine. However, it usually happens that they continue to use the already open version of the application, that is, the version serviced before the update, and then experience unclear errors related to RPC, since Javascript on the client side no longer synchronizes with what is on the server.

Does GWT have any mechanism you can enable or include in your code to handle this. I do not need any smart handling of the situation, for example. trying to restart the application and restore the current state of the user, a simple dialog box explaining that the client and server are no longer synchronized and that the web application needs to be restarted would be enough.

+5
source share
2 answers

The interface documentation com.google.gwt.user.client.rpc.AsyncCallback<T>provides a hint on how to do this.

   public void onFailure(Throwable caught) {
     // Convenient way to find out which exception was thrown.
     try {
       throw caught;
     } catch (IncompatibleRemoteServiceException e) {
       // this client is not compatible with the server; cleanup and refresh the 
       // browser
     } catch (InvocationException e) {
       // the call didn't complete cleanly
     } catch (ShapeException e) {
       // one of the 'throws' from the original method
     } catch (DbException e) {
       // one of the 'throws' from the original method
     } catch (Throwable e) {
       // last resort -- a very unexpected exception
     }
   }

You will most likely want to process (pop-up user dialog) IncompatibleRemoteServiceException.

+4
source

All Articles