@Override public Mono<Void> close(CloseStatus status) { try { CloseReason.CloseCode code = CloseCodes.getCloseCode(status.getCode()); getDelegate().close(new CloseReason(code, status.getReason())); } catch (IOException ex) { return Mono.error(ex); } return Mono.empty(); }
static void closeSilently( final Session session, final CloseCodes code, final String message) { try { session.close(new CloseReason(code, truncate(message))); } catch (final Exception e) { LOG.info("Exception caught closing session {}", session.getId(), e); } }
/** * Sends the numeric Guacaomle Status Code and Web Socket * code and closes the connection. * * @param session * The outbound WebSocket connection to close. * * @param guacamoleStatusCode * The numeric Guacamole status to send. * * @param webSocketCode * The numeric WebSocket status to send. */ private void closeConnection(Session session, int guacamoleStatusCode, int webSocketCode) { try { CloseCode code = CloseReason.CloseCodes.getCloseCode(webSocketCode); String message = Integer.toString(guacamoleStatusCode); session.close(new CloseReason(code, message)); } catch (IOException e) { logger.debug("Unable to close WebSocket connection.", e); } }
@Override protected void closeInternal(CloseStatus status) throws IOException { getNativeSession().close(new CloseReason(CloseCodes.getCloseCode(status.getCode()), status.getReason())); }
/** * Close the session informing the reason. */ public void close( String message ) throws KettleException { sessionValid(); try { if ( this.userSession != null && this.userSession.isOpen() ) { this.userSession.close( new CloseReason( CloseReason.CloseCodes.NORMAL_CLOSURE, message ) ); } } catch ( IOException e ) { throw new KettleException( e ); } }
session.close(new CloseReason(CloseReason.CloseCodes.CANNOT_ACCEPT, "Handshake not accepted.")); } catch (IOException e) { logger.trace("", e); } else { logger.trace("Session closed during onOpen {}", session); onClose(session, new CloseReason(CloseReason.CloseCodes.GOING_AWAY, "Session closed already")); session.close(new CloseReason(CloseReason.CloseCodes.UNEXPECTED_CONDITION, e.getMessage())); } catch (IOException e1) { logger.trace("", e);
@Test public void onClose() throws Throwable { this.adapter.onClose(this.session, new CloseReason(CloseCodes.NORMAL_CLOSURE, "reason")); verify(this.webSocketHandler).afterConnectionClosed(this.webSocketSession, CloseStatus.NORMAL.withReason("reason")); }
@Override public CloseReason getCloseReason() { return new CloseReason(CloseReason.CloseCodes.PROTOCOL_ERROR, reasonPhrase); } }
protected void checkExpiration() { long timeout = maxIdleTimeout; if (timeout < 1) { return; } if (System.currentTimeMillis() - lastActive > timeout) { String msg = sm.getString("wsSession.timeout"); doClose(new CloseReason(CloseCodes.GOING_AWAY, msg), new CloseReason(CloseCodes.CLOSED_ABNORMALLY, msg)); } }
protected void checkExpiration() { long timeout = maxIdleTimeout; if (timeout < 1) { return; } if (System.currentTimeMillis() - lastActive > timeout) { String msg = sm.getString("wsSession.timeout"); doClose(new CloseReason(CloseCodes.GOING_AWAY, msg), new CloseReason(CloseCodes.CLOSED_ABNORMALLY, msg)); } }
@OnOpen public void onOpen(Session session) { if(session.getOpenSessions().size() > maxConnections) { session.close(new CloseReason(...)); } // ... }
private void closeSession(Exception e) { LOG.debug("Consumer initiated close of session {}", session.getId()); try { session.close(new CloseReason(CloseReason.CloseCodes.CLOSED_ABNORMALLY, e.getMessage())); } catch (IOException ioe) { LOG.error("Error closing session: {}", ioe.getMessage()); } } }
public void close() { availableSessionsById.values().forEach(session -> { if (session.isOpen()) { try { session.close(new CloseReason(CloseCodes.GOING_AWAY, "Server is going down")); } catch (Exception e) { logger.warn("Unexpected error while shutting down Web Socket session", e); } } }); } }
public void close(Double opCode, String aReason) throws Exception { if (opCode == null) { opCode = Double.valueOf(CloseReason.CloseCodes.NO_STATUS_CODE.getCode()); } if (aReason == null) { aReason = ""; } if (session.isOpen()) { session.close(new CloseReason(CloseReason.CloseCodes.getCloseCode(opCode.intValue()), aReason)); } }
@Override public void close() throws IOException { cleanAfterClose(); changeStateToClosed(); basicRemote.close(new CloseReason(CloseReason.CloseCodes.NORMAL_CLOSURE, null)); }
@ScriptFunction public void close(Double opCode, String aReason) throws Exception { if (opCode == null) { opCode = Double.valueOf(CloseReason.CloseCodes.NO_STATUS_CODE.getCode()); } if (aReason == null) { aReason = ""; } if (webSocketSession.isOpen()) { webSocketSession.close(new CloseReason(CloseReason.CloseCodes.getCloseCode(opCode.intValue()), aReason)); } }
@Override public Mono<Void> close(CloseStatus status) { try { CloseReason.CloseCode code = CloseCodes.getCloseCode(status.getCode()); getDelegate().close(new CloseReason(code, status.getReason())); } catch (IOException e) { return Mono.error(e); } return Mono.empty(); }
private void handleThrowableOnSend(Throwable t) throws WsIOException { ExceptionUtils.handleThrowable(t); wsSession.getLocal().onError(wsSession, t); CloseReason cr = new CloseReason(CloseCodes.CLOSED_ABNORMALLY, sm.getString("wsFrame.ioeTriggeredClose")); throw new WsIOException(cr); }
private void handleThrowableOnSend(Throwable t) throws WsIOException { ExceptionUtils.handleThrowable(t); wsSession.getLocal().onError(wsSession, t); CloseReason cr = new CloseReason(CloseCodes.CLOSED_ABNORMALLY, MESSAGES.closeAfterError()); throw new WsIOException(cr); }
private void handleThrowableOnSend(Throwable t) throws WsIOException { ExceptionUtils.handleThrowable(t); wsSession.getLocal().onError(wsSession, t); CloseReason cr = new CloseReason(CloseCodes.CLOSED_ABNORMALLY, sm.getString("wsFrame.ioeTriggeredClose")); throw new WsIOException(cr); }