Search in sources :

Example 1 with OnError

use of javax.websocket.OnError in project tomcat by apache.

the class SnakeAnnotation method onError.

@OnError
public void onError(Throwable t) throws Throwable {
    // Most likely cause is a user closing their browser. Check to see if
    // the root cause is EOF and if it is ignore it.
    // Protect against infinite loops.
    int count = 0;
    Throwable root = t;
    while (root.getCause() != null && count < 20) {
        root = root.getCause();
        count++;
    }
    if (root instanceof EOFException) {
    // Assume this is triggered by the user closing their browser and
    // ignore it.
    } else {
        throw t;
    }
}
Also used : EOFException(java.io.EOFException) ServerEndpoint(javax.websocket.server.ServerEndpoint) OnError(javax.websocket.OnError)

Example 2 with OnError

use of javax.websocket.OnError in project tomcat70 by apache.

the class SnakeAnnotation method onError.

@OnError
public void onError(Throwable t) throws Throwable {
    // Most likely cause is a user closing their browser. Check to see if
    // the root cause is EOF and if it is ignore it.
    // Protect against infinite loops.
    int count = 0;
    Throwable root = t;
    while (root.getCause() != null && count < 20) {
        root = root.getCause();
        count++;
    }
    if (root instanceof EOFException) {
    // Assume this is triggered by the user closing their browser and
    // ignore it.
    } else {
        throw t;
    }
}
Also used : EOFException(java.io.EOFException) ServerEndpoint(javax.websocket.server.ServerEndpoint) OnError(javax.websocket.OnError)

Aggregations

EOFException (java.io.EOFException)2 OnError (javax.websocket.OnError)2 ServerEndpoint (javax.websocket.server.ServerEndpoint)2