How to handle your Internet connection in the GWT app

I am processing a website that is developed by GWT, and I want to check if the internet connection between access to the website is decreasing. If the Internet does not work, I want to give a message, because I can’t connect to the server or something like Gmail processes it.

Can anyone suggest what would be the best way to handle this?

+3
source share
1 answer

This is the method onFailure(Throwable t)on AsyncCallback. This method is called when the RPC fails for any reason, including (but not limited to) loss of connection.

Because Throwablewhich is passed in onFailure()can be anything, the template used in documents:

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
  // other Throwables may be caught here...
  } catch (Throwable e) {
    // last resort -- a very unexpected exception
  }
}

, InvocationException onFailure()

+2

Source: https://habr.com/ru/post/1740559/


All Articles