/** * 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 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(); }
@Override public void close(final int code, String reason) { try { // Limits of the WebSocket APIs, otherwise an exception is thrown. reason = reason.substring(0, Math.min(reason.length(), 30)); if (_logger.isDebugEnabled()) { _logger.debug("Closing {}/{}", code, reason); } _wsSession.close(new CloseReason(CloseReason.CloseCodes.getCloseCode(code), reason)); } catch (Throwable x) { _logger.trace("Could not close WebSocket session " + _wsSession, x); } }
static CloseCode getCloseCode(int code) { if (code > 2999 && code < 5000) { return CloseCodes.getCloseCode(code);
static CloseCode getCloseCode(int code) { if (code > 2999 && code < 5000) { return CloseCodes.getCloseCode(code);
static CloseCode getCloseCode(int code) { if (code > 2999 && code < 5000) { return CloseCodes.getCloseCode(code);
closeReason = new CloseReason(CloseReason.CloseCodes.getCloseCode(closeCode), closeReasonString);
closeReason = new CloseReason(CloseReason.CloseCodes.getCloseCode(closeCode), closeReasonString);
@Override public void onClose(ClosingFrame dataFrame) { onConnectLatch.countDown(); if (state.get() == State.CLOSED) { return; } if (!state.compareAndSet(State.CLOSING, State.CLOSED)) { state.set(State.CLOSED); protocolHandler.doClose(); closeTransport(); } CloseReason closeReason = null; if (dataFrame != null) { closeReason = new CloseReason(CloseReason.CloseCodes.getCloseCode(dataFrame.getCode()), dataFrame.getReason()); } endpoint.onClose(remoteEndpoint, closeReason); }
public synchronized Future<Frame> close(final int code, final String reason) { final CloseFrame outgoingCloseFrame; final CloseReason closeReason = new CloseReason(CloseReason.CloseCodes.getCloseCode(code), reason); if (code == CloseReason.CloseCodes.NO_STATUS_CODE.getCode() || code == CloseReason.CloseCodes.CLOSED_ABNORMALLY.getCode() || code == CloseReason.CloseCodes.TLS_HANDSHAKE_FAILURE.getCode() // client side cannot send SERVICE_RESTART or TRY_AGAIN_LATER // will be replaced with NORMAL_CLOSURE || (client && (code == CloseReason.CloseCodes.SERVICE_RESTART.getCode() || code == CloseReason.CloseCodes.TRY_AGAIN_LATER.getCode()))) { outgoingCloseFrame = new CloseFrame(new CloseReason(CloseReason.CloseCodes.NORMAL_CLOSURE, reason)); } else { outgoingCloseFrame = new CloseFrame(closeReason); } final Future<Frame> send = send(outgoingCloseFrame, null, false); webSocket.onClose(new CloseFrame(closeReason)); return send; }
private void httpSessionForcedClose(int closeCode, String closeReason) { if (!closed) { try { // TODO // initiates connection close without sending close frame to the client - session is already invalidated // so we should not send anything. // ((TyrusWebSocket) ((TyrusWebSocketEngine) engine).getWebSocketHolder(writer).webSocket).setClosed(); connection.close(new CloseReason(CloseReason.CloseCodes.getCloseCode(closeCode), closeReason)); closed = true; wc.close(); } catch (Exception e) { LOGGER.log(Level.CONFIG, e.getMessage(), e); } } }
public synchronized Future<Frame> close(final int code, final String reason) { final CloseFrame outgoingCloseFrame; final CloseReason closeReason = new CloseReason(CloseReason.CloseCodes.getCloseCode(code), reason); if (code == CloseReason.CloseCodes.NO_STATUS_CODE.getCode() || code == CloseReason.CloseCodes.CLOSED_ABNORMALLY.getCode() || code == CloseReason.CloseCodes.TLS_HANDSHAKE_FAILURE.getCode() // client side cannot send SERVICE_RESTART or TRY_AGAIN_LATER // will be replaced with NORMAL_CLOSURE || (client && (code == CloseReason.CloseCodes.SERVICE_RESTART.getCode() || code == CloseReason.CloseCodes.TRY_AGAIN_LATER.getCode()))) { outgoingCloseFrame = new CloseFrame(new CloseReason(CloseReason.CloseCodes.NORMAL_CLOSURE, reason)); } else { outgoingCloseFrame = new CloseFrame(closeReason); } final Future<Frame> send = send(outgoingCloseFrame, null, false); webSocket.onClose(new CloseFrame(closeReason)); return send; }
@Override protected void closeInternal(CloseStatus status) throws IOException { getNativeSession().close(new CloseReason(CloseCodes.getCloseCode(status.getCode()), status.getReason())); }
@Override public boolean close(int status, String reason) { if (!readyState.equals(OPEN)) { return false; } readyState = CLOSING; try { ws.close(new CloseReason(CloseReason.CloseCodes.getCloseCode(status), reason)); } catch (IOException ex) { log.log(Level.FINE, "Error closing raw websocket", ex); } return true; }
private void close(int closeCode, String closeReason) { if (!closed) { try { connection.close(new CloseReason(CloseReason.CloseCodes.getCloseCode(closeCode), closeReason)); closed = true; wc.close(); } catch (Exception e) { LOGGER.log(Level.CONFIG, e.getMessage(), e); } } }
@Override protected void closeInternal(CloseStatus status) throws IOException { getNativeSession().close(new CloseReason(CloseCodes.getCloseCode(status.getCode()), status.getReason())); }
@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(); }
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)); } }
@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 protected void closeInternal(CloseStatus status) throws IOException { getNativeSession().close(new CloseReason(CloseCodes.getCloseCode(status.getCode()), status.getReason())); }