protected void onTimeout(boolean useDispatch) { if (handler != null) { clearHandler(new SocketTimeoutException(), useDispatch); } close(); }
@Override public void backgroundProcess() { // This method gets called once a second. backgroundProcessCount ++; if (backgroundProcessCount >= processPeriod) { backgroundProcessCount = 0; long now = System.currentTimeMillis(); for (WsRemoteEndpointImplServer endpoint : endpoints) { if (endpoint.getTimeoutExpiry() < now) { // Background thread, not the thread that triggered the // write so no need to use a dispatch endpoint.onTimeout(false); } else { // Endpoints are ordered by timeout expiry so if this point // is reached there is no need to check the remaining // endpoints break; } } } }
@Override public void onWritePossible() { // Triggered by the poller so this isn't the same thread that // triggered the write so no need for a dispatch wsRemoteEndpointServer.onWritePossible(false); }
clearHandler(null, useDispatch); if (close) { close(); clearHandler(ioe, useDispatch); close(); long timeout = getSendTimeout(); if (timeout > 0) {
t.setContextClassLoader(applicationClassLoader); try { wsRemoteEndpointServer = new WsRemoteEndpointImplServer(socketWrapper, webSocketContainer); wsSession = new WsSession(ep, wsRemoteEndpointServer, webSocketContainer, handshakeRequest.getRequestURI(), wsRemoteEndpointServer.setTransformation(wsFrame.getTransformation()); ep.onOpen(wsSession, endpointConfig); webSocketContainer.registerSession(ep, wsSession);
wsWriteTimeout.register(this); timeout = getSendTimeout(); onWritePossible(true); } else {
@Override public void onError(Throwable throwable) { wsProtocolHandler.onError(throwable); wsRemoteEndpointServer.close(); } }
@Override public int compare(WsRemoteEndpointImplServer o1, WsRemoteEndpointImplServer o2) { long t1 = o1.getTimeoutExpiry(); long t2 = o2.getTimeoutExpiry(); if (t1 < t2) { return -1; } else if (t1 == t2) { return 0; } else { return 1; } } }
@Override protected void doClose() { if (handler != null) { // close() can be triggered by a wide range of scenarios. It is far // simpler just to always use a dispatch than it is to try and track // whether or not this method was called by the same thread that // triggered the write clearHandler(new EOFException(), true); } try { sos.close(); } catch (IOException e) { WebsocketsLogger.ROOT_LOGGER.closeFailed(e); } wsWriteTimeout.unregister(this); }
try { WsRemoteEndpointImplServer wsRemoteEndpointServer = new WsRemoteEndpointImplServer(sos, webSocketContainer); wsSession = new WsSession(ep, wsRemoteEndpointServer, webSocketContainer, handshakeRequest.getRequestURI(),
clearHandler(null, useDispatch); if (close) { close(); clearHandler(ioe, useDispatch); close(); long timeout = getSendTimeout(); if (timeout > 0) {
t.setContextClassLoader(applicationClassLoader); try { wsRemoteEndpointServer = new WsRemoteEndpointImplServer(socketWrapper, webSocketContainer); wsSession = new WsSession(ep, wsRemoteEndpointServer, webSocketContainer, handshakeRequest.getRequestURI(), wsRemoteEndpointServer.setTransformation(wsFrame.getTransformation()); ep.onOpen(wsSession, endpointConfig); webSocketContainer.registerSession(ep, wsSession);
wsWriteTimeout.register(this); timeout = getSendTimeout(); onWritePossible(true); } else {
@Override public void onError(Throwable throwable) { wsProtocolHandler.onError(throwable); wsRemoteEndpointServer.close(); } }
@Override public int compare(WsRemoteEndpointImplServer o1, WsRemoteEndpointImplServer o2) { long t1 = o1.getTimeoutExpiry(); long t2 = o2.getTimeoutExpiry(); if (t1 < t2) { return -1; } else if (t1 == t2) { return 0; } else { return 1; } } }
@Override protected void doClose() { if (handler != null) { // close() can be triggered by a wide range of scenarios. It is far // simpler just to always use a dispatch than it is to try and track // whether or not this method was called by the same thread that // triggered the write clearHandler(new EOFException(), true); } try { sos.close(); } catch (IOException e) { if (log.isInfoEnabled()) { log.info(sm.getString("wsRemoteEndpointServer.closeFailed"), e); } } wsWriteTimeout.unregister(this); }
if (complete) { wsWriteTimeout.unregister(this); clearHandler(null, useDispatch); if (close) { close(); clearHandler(ioe, useDispatch); close(); long timeout = getSendTimeout(); if (timeout > 0) {
protected void onTimeout(boolean useDispatch) { if (handler != null) { clearHandler(new SocketTimeoutException(), useDispatch); } close(); }
@Override public void backgroundProcess() { // This method gets called once a second. backgroundProcessCount ++; if (backgroundProcessCount >= processPeriod) { backgroundProcessCount = 0; long now = System.currentTimeMillis(); for (WsRemoteEndpointImplServer endpoint : endpoints) { if (endpoint.getTimeoutExpiry() < now) { // Background thread, not the thread that triggered the // write so no need to use a dispatch endpoint.onTimeout(false); } else { // Endpoints are ordered by timeout expiry so if this point // is reached there is no need to check the remaining // endpoints break; } } } }
try { WsRemoteEndpointImplServer wsRemoteEndpointServer = new WsRemoteEndpointImplServer(sos, webSocketContainer); wsSession = new WsSession(ep, wsRemoteEndpointServer, webSocketContainer, handshakeRequest.getRequestURI(), wsRemoteEndpointServer.setTransformation(wsFrame.getTransformation()); ep.onOpen(wsSession, endpointConfig); webSocketContainer.registerSession(ep, wsSession);