Example usage for javax.websocket CloseReason getReasonPhrase

List of usage examples for javax.websocket CloseReason getReasonPhrase

Introduction

In this page you can find the example usage for javax.websocket CloseReason getReasonPhrase.

Prototype

public String getReasonPhrase() 

Source Link

Usage

From source file:org.jboss.as.quickstarts.websocket_hello.HelloName.java

@OnClose
public void helloOnClose(CloseReason reason) {
    System.out.println("Closing a WebSocket due to " + reason.getReasonPhrase());
}

From source file:DataReceiverEndpoint.java

public void onClose(Session session, CloseReason reason) {
    if (log.isDebugEnabled()) {
        log.debug("Closing a WebSocket due to " + reason.getReasonPhrase() + ", for session ID:"
                + session.getId() + ", for request URI - " + session.getRequestURI());
    }/* ww w. j a  va 2s.c  o m*/
}

From source file:com.almende.eve.transport.ws.WebsocketTransport.java

/**
 * On close.//from w w  w.  j av a2 s  .c  o m
 * 
 * @param session
 *            the session
 * @param closeReason
 *            the close reason
 */
public void onClose(final Session session, final CloseReason closeReason) {
    LOG.info("Connection closed:" + closeReason.getReasonPhrase() + "(" + closeReason.getCloseCode().getCode()
            + ":" + closeReason.getCloseCode().toString() + ")");
    setConnected(false);
}

From source file:TopicSubscriptionEndpoint.java

public void onClose(Session session, CloseReason reason, String topic, String adaptorName, int tenantId) {
    if (log.isDebugEnabled()) {
        log.debug("Closing a WebSocket due to " + reason.getReasonPhrase() + ", for session ID:"
                + session.getId() + ", for request URI - " + session.getRequestURI());
    }/*from  www.ja  v a 2 s  .c o  m*/
    websocketLocalOutputCallbackRegisterService.unsubscribe(tenantId, adaptorName, topic, session);
}

From source file:org.jboss.aerogear.sync.server.wildfly.SyncEndpoint.java

@OnClose
public void onClose(CloseReason reason, Session webSocketSession) {
    logger.info("Closing a WebSocket due to " + reason.getReasonPhrase());
    WildflySubscriber subscriber = (WildflySubscriber) webSocketSession.getUserProperties()
            .get(WILDFLY_SUBSCRIBER);/*from   ww w  .  ja  va  2  s .  c om*/
    String documentId = (String) webSocketSession.getUserProperties().get(DOCUMENT_ID);
    syncEngine.removeSubscriber(subscriber, documentId);

}

From source file:SubscriptionEndpoint.java

public void onClose(Session session, CloseReason reason, String adaptorName, int tenantId) {
    if (log.isDebugEnabled()) {
        log.debug("Closing a WebSocket due to " + reason.getReasonPhrase() + ", for session ID:"
                + session.getId() + ", for request URI - " + session.getRequestURI());
    }/* w  ww  .  j ava  2  s  . c  o  m*/

    try {
        PrivilegedCarbonContext.startTenantFlow();
        PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId);
        websocketLocalOutputCallbackRegisterService.unsubscribe(adaptorName, session);
    } finally {
        PrivilegedCarbonContext.endTenantFlow();
    }
}

From source file:cito.server.AbstractEndpoint.java

@OnClose
@Override//from  w  w w  .  j av  a2s  .c o  m
public void onClose(Session session, CloseReason reason) {
    this.log.info("WebSocket connection closed. [id={},principle={},code={},reason={}]", session.getId(),
            session.getUserPrincipal(), reason.getCloseCode(), reason.getReasonPhrase());
    final WebSocketContext ctx = webSocketContext(this.beanManager);
    try (QuietClosable c = ctx.activate(session)) {
        this.registry.unregister(session);
        this.sessionEvent.select(cito.annotation.OnClose.Literal.onClose()).fire(session);
    }
    ctx.dispose(session);
}

From source file:io.apicurio.hub.editing.EditApiDesignEndpoint.java

@OnClose
public void onCloseSession(Session session, CloseReason reason) {
    String designId = session.getPathParameters().get("designId");
    logger.debug("Closing a WebSocket due to: {}", reason.getReasonPhrase());
    logger.debug("\tdesignId: {}", designId);

    // Call 'leave' on the concurrent editing session for this user
    ApiDesignEditingSession editingSession = editingSessionManager.getEditingSession(designId);
    String userId = editingSession.getUser(session);
    editingSession.leave(session);//from  ww w  .  j av  a2 s  .  c om
    if (editingSession.isEmpty()) {
        // TODO race condition - the session may no longer be empty here!
        editingSessionManager.closeEditingSession(editingSession);

        try {
            rollupCommands(userId, designId);
        } catch (NotFoundException | StorageException | OaiCommandException e) {
            logger.error("Failed to rollup commands for API with id: " + designId, "Rollup error: ", e);
        }
    } else {
        editingSession.sendLeaveToOthers(session, userId);
    }
}

From source file:org.axonframework.commandhandling.distributed.websockets.WebsocketCommandBusConnectorClient.java

@Override
public void onClose(Session session, CloseReason closeReason) {
    if (closeReason.getCloseCode() != CloseReason.CloseCodes.NORMAL_CLOSURE) {
        LOGGER.warn("Session closed because " + closeReason.getReasonPhrase());
    }//ww  w  .  ja  v  a2  s. com
    try {
        sessions.invalidateObject(session);
        repository.cancelCallbacks(session.getId());
    } catch (Exception e) {
        LOGGER.error("Could not invalidate session", e);
    }
}

From source file:org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.java

@Override
public void onClose(javax.websocket.Session session, CloseReason reason) {
    CloseStatus closeStatus = new CloseStatus(reason.getCloseCode().getCode(), reason.getReasonPhrase());
    try {/*ww w.j  a v  a  2s. c  om*/
        this.handler.afterConnectionClosed(this.wsSession, closeStatus);
    } catch (Throwable ex) {
        if (logger.isWarnEnabled()) {
            logger.warn("Unhandled on-close exception for " + this.wsSession, ex);
        }
    }
}