Refine search
@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(); }
private void sendCloseMessage(CloseReason closeReason) { // 125 is maximum size for the payload of a control message ByteBuffer msg = ByteBuffer.allocate(125); CloseCode closeCode = closeReason.getCloseCode(); // CLOSED_ABNORMALLY should not be put on the wire if (closeCode == CloseCodes.CLOSED_ABNORMALLY) { // PROTOCOL_ERROR is probably better than GOING_AWAY here msg.putShort((short) CloseCodes.PROTOCOL_ERROR.getCode()); } else { msg.putShort((short) closeCode.getCode()); } String reason = closeReason.getReasonPhrase(); if (reason != null && reason.length() > 0) { appendCloseReasonWithTruncation(msg, reason); } msg.flip(); try { wsRemoteEndpoint.startMessageBlock(Constants.OPCODE_CLOSE, msg, true); } catch (IOException ioe) { handleCloseException(ioe, closeCode); } catch (WritePendingException wpe) { handleCloseException(wpe, closeCode); } finally { webSocketContainer.unregisterSession(localEndpoint, this); } }
if (!(CloseReason.CloseCodes.CLOSED_ABNORMALLY.equals(closeReason.getCloseCode()) || CloseReason.CloseCodes.GOING_AWAY.equals(closeReason.getCloseCode()))) { clusterContext.destroyDistributedUserProperties(session.getConnectionId());
/** * will close all current realTime sessions bound to the current HTTP * session */ public void invalidateSession() { for (SockJsConnection connection : sessions) { connection.close( javax.websocket.CloseReason.CloseCodes.CANNOT_ACCEPT .getCode(), "CLOSED BY BACKEND"); } }
/** * Closes this {@link TyrusWebSocket}. */ public void close() { close(CloseReason.CloseCodes.NORMAL_CLOSURE.getCode(), null); }
@Override public void onError(Throwable t) { close(CloseReason.CloseCodes.CLOSED_ABNORMALLY.getCode(), t.getMessage() == null ? "No reason given." : t.getMessage()); }
@Override public void close() { close(CloseReason.CloseCodes.NORMAL_CLOSURE.getCode(), "Closing"); }
/** * Closes this {@link TyrusWebSocket}. */ public void close() { close(CloseReason.CloseCodes.NORMAL_CLOSURE.getCode(), null); }
@Override public void destroy() { close(CloseReason.CloseCodes.CLOSED_ABNORMALLY.getCode(), "No reason given."); }
/** * Called when related {@link javax.servlet.http.HttpSession} is destroyed or invalidated. * <p> * Implementation is required to call onClose() on server-side with corresponding close code (1008, see * WebSocket spec 7.2) - only when there is an authorized user for this session. */ public void sessionDestroyed() { if (authenticated) { // websocket spec 7.2 [WSC-7.2-3] httpSessionForcedClose(CloseReason.CloseCodes.VIOLATED_POLICY.getCode(), "No reason given."); } // else do nothing. }
@Override public void onAllDataRead() { close(CloseReason.CloseCodes.NORMAL_CLOSURE.getCode(), null); }
@OnClose public void sessionClosed(Session websocketSession) throws Exception { PlatypusServerCore platypusCore = lookupPlaypusServerCore(); in(platypusCore, websocketSession, (com.eas.server.Session aSession) -> { Logger.getLogger(JsServerModuleEndPoint.class.getName()).log(Level.FINE, "WebSocket container OnClose {0}.", aSession.getId()); JSObject closeEvent = Scripts.getSpace().makeObj(); closeEvent.setMember("wasClean", true); closeEvent.setMember("code", CloseReason.CloseCodes.NORMAL_CLOSURE.getCode()); closeEvent.setMember("reason", ""); closeEvent.setMember("id", websocketSession.getId()); platypusCore.executeMethod(moduleName, WS_ON_CLOSE, new Object[]{closeEvent}, true, (Object aResult) -> { com.eas.server.Session session = SessionManager.Singleton.instance.remove(wasPlatypusSessionId); Logger.getLogger(JsServerModuleEndPoint.class.getName()).log(Level.INFO, "WebSocket platypus session closed. Session id: {0}", session.getId()); Logger.getLogger(JsServerModuleEndPoint.class.getName()).log(Level.FINE, "{0} method of {1} module called successfully.", new Object[]{WS_ON_CLOSE, moduleName}); }, (Exception ex) -> { com.eas.server.Session session = SessionManager.Singleton.instance.remove(wasPlatypusSessionId); Logger.getLogger(JsServerModuleEndPoint.class.getName()).log(Level.INFO, "WebSocket platypus session closed. Session id: {0}", session.getId()); Logger.getLogger(JsServerModuleEndPoint.class.getName()).log(Level.SEVERE, null, ex); }); }); }
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);
private void sendCloseMessage(CloseReason closeReason) { CloseCode closeCode = closeReason.getCloseCode(); msg.putShort((short) CloseCodes.PROTOCOL_ERROR.getCode()); } else { msg.putShort((short) closeCode.getCode()); String reason = closeReason.getReasonPhrase(); if (reason != null && reason.length() > 0) { appendCloseReasonWithTruncation(msg, reason);
if (!(CloseReason.CloseCodes.CLOSED_ABNORMALLY.equals(closeReason.getCloseCode()) || CloseReason.CloseCodes.GOING_AWAY.equals(closeReason.getCloseCode()))) { clusterContext.destroyDistributedUserProperties(session.getConnectionId());
/** * 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); } }
private void sendCloseMessage(CloseReason closeReason) { CloseCode closeCode = closeReason.getCloseCode(); msg.putShort((short) CloseCodes.PROTOCOL_ERROR.getCode()); } else { msg.putShort((short) closeCode.getCode()); String reason = closeReason.getReasonPhrase(); if (reason != null && reason.length() > 0) { appendCloseReasonWithTruncation(msg, reason);
@Override protected void closeInternal(CloseStatus status) throws IOException { getNativeSession().close(new CloseReason(CloseCodes.getCloseCode(status.getCode()), status.getReason())); }