use of org.apache.tomcat.websocket.WsIOException in project tomcat by apache.
the class WsHttpUpgradeHandler method upgradeDispatch.
@Override
public SocketState upgradeDispatch(SocketEvent status) {
switch(status) {
case OPEN_READ:
try {
return wsFrame.notifyDataAvailable();
} catch (WsIOException ws) {
close(ws.getCloseReason());
} catch (IOException ioe) {
onError(ioe);
CloseReason cr = new CloseReason(CloseCodes.CLOSED_ABNORMALLY, ioe.getMessage());
close(cr);
}
return SocketState.CLOSED;
case OPEN_WRITE:
wsRemoteEndpointServer.onWritePossible(false);
break;
case STOP:
CloseReason cr = new CloseReason(CloseCodes.GOING_AWAY, sm.getString("wsHttpUpgradeHandler.serverStop"));
try {
wsSession.close(cr);
} catch (IOException ioe) {
onError(ioe);
cr = new CloseReason(CloseCodes.CLOSED_ABNORMALLY, ioe.getMessage());
close(cr);
return SocketState.CLOSED;
}
break;
case ERROR:
String msg = sm.getString("wsHttpUpgradeHandler.closeOnError");
wsSession.doClose(new CloseReason(CloseCodes.GOING_AWAY, msg), new CloseReason(CloseCodes.CLOSED_ABNORMALLY, msg));
// $FALL-THROUGH$
case DISCONNECT:
case TIMEOUT:
case CONNECT_FAIL:
return SocketState.CLOSED;
}
if (wsFrame.isOpen()) {
return SocketState.UPGRADED;
} else {
return SocketState.CLOSED;
}
}
Aggregations