/** * Jetty Connection Close */ @Override public void close() { session.close(); }
@Override public void close() { /* This is assumed to always be a NORMAL closure, no reason phrase */ close(new CloseInfo(StatusCode.NORMAL), null); }
@Override public void close(int statusCode, String reason) { close(new CloseInfo(statusCode, reason), null); }
protected void closeAllConnections() { for (WebSocketSession session : sessions) { try { session.close(); } catch (IOException e) { LOG.warn("CloseAllConnections Close failure",e); } } sessions.clear(); }
protected void closeAllConnections() { for (WebSocketSession session : sessions) { try { session.close(); } catch (IOException e) { LOG.warn("CloseAllConnections Close failure",e); } } sessions.clear(); }
@Override public void close(CloseStatus closeStatus) { this.close(closeStatus.getCode(),closeStatus.getPhrase()); }
protected void terminateConnection(int statusCode, String rawreason) { String reason = rawreason; reason = StringUtil.truncate(reason,(WebSocketFrame.MAX_CONTROL_PAYLOAD - 2)); LOG.debug("terminateConnection({},{})",statusCode,rawreason); session.close(statusCode,reason); }
/** * Aborts the active session abruptly. * @param statusCode the status code * @param reason the raw reason code */ public void abort(int statusCode, String reason) { close(new CloseInfo(statusCode, reason), new DisconnectCallback()); }
@Override public void close(CloseStatus closeStatus) { this.close(closeStatus.getCode(),closeStatus.getPhrase()); }
protected void terminateConnection(int statusCode, String rawreason) { String reason = rawreason; reason = StringUtil.truncate(reason,(WebSocketFrame.MAX_CONTROL_PAYLOAD - 2)); LOG.debug("terminateConnection({},{})",statusCode,rawreason); session.close(statusCode,reason); }
protected void terminateConnection(int statusCode, String rawreason) { if (LOG.isDebugEnabled()) LOG.debug("terminateConnection({},{})",statusCode,rawreason); session.close(statusCode,CloseFrame.truncate(rawreason)); }
@Override public void close(CloseStatus closeStatus) { close(new CloseInfo(closeStatus.getCode(),closeStatus.getPhrase()), null); }
@Override protected void doStop() throws Exception { if(LOG.isDebugEnabled()) LOG.debug("stopping - {}",this); try { close(StatusCode.SHUTDOWN,"Shutdown"); } catch (Throwable t) { LOG.debug("During Connection Shutdown",t); } super.doStop(); }
@Override protected boolean onReadTimeout() { LOG.warn("Read Timeout"); IOState state = getIOState(); if ((state.getState() == ConnectionState.CLOSING) || (state.getState() == ConnectionState.CLOSED)) { // close already initiated, extra timeouts not relevant // allow udnerlying connection and endpoint to disconnect on its own return true; } // Initiate close - politely send close frame. // Note: it is not possible in 100% of cases during read timeout to send this close frame. session.close(StatusCode.NORMAL,"Idle Timeout"); return false; }
@Override protected boolean onReadTimeout() { LOG.warn("Read Timeout"); IOState state = getIOState(); if ((state.getState() == ConnectionState.CLOSING) || (state.getState() == ConnectionState.CLOSED)) { // close already initiated, extra timeouts not relevant // allow udnerlying connection and endpoint to disconnect on its own return true; } // Initiate close - politely send close frame. // Note: it is not possible in 100% of cases during read timeout to send this close frame. session.close(StatusCode.NORMAL,"Idle Timeout"); return false; }
/** * Event for no activity on connection (read or write) * @return true to signal that the endpoint must be closed, false to keep the endpoint open */ @Override protected boolean onReadTimeout(Throwable timeout) { IOState state = getIOState(); ConnectionState cstate = state.getConnectionState(); if (LOG.isDebugEnabled()) LOG.debug("{} Read Timeout - {}",policy.getBehavior(),cstate); if (cstate == ConnectionState.CLOSED) { if (LOG.isDebugEnabled()) LOG.debug("onReadTimeout - Connection Already CLOSED"); // close already completed, extra timeouts not relevant // allow underlying connection and endpoint to disconnect on its own return true; } try { notifyError(timeout); } finally { // This is an Abnormal Close condition session.close(StatusCode.SHUTDOWN,"Idle Timeout"); } return false; }
session.close(e.getStatusCode(),e.getMessage()); return ReadMode.DISCARD;
session.close(close.getStatusCode(),close.getReason());