Example usage for javax.websocket Session getId

List of usage examples for javax.websocket Session getId

Introduction

In this page you can find the example usage for javax.websocket Session getId.

Prototype

String getId();

Source Link

Document

Provides a unique identifier for the session.

Usage

From source file:SubscriptionEndpoint.java

public void onError(Session session, Throwable throwable, String adaptorName, int tenantId) {
    log.error("Error occurred in session ID: " + session.getId() + ", for request URI - "
            + session.getRequestURI() + ", " + throwable.getMessage(), throwable);

    try {/*from  ww w .  j av  a2s .  c o  m*/

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

From source file:fr.feedreader.websocket.UpdateFeed.java

@OnOpen
public void onOpen(Session session, EndpointConfig config) {
    availableSession.add(session);/* w  w w  .  java  2s . c  o m*/
    LogManager.getLogger().info("Opening websocket !!!! " + session.getId());
}

From source file:com.cosplay.websocket.ChatAnnotation.java

@OnOpen
public void start(Session session) {
    this.session = session;
    System.out.println("session id :" + session.getId());
    connections.add(this);
    String message = String.format("* %s %s", nickname, "has joined.");
    broadcast(message);//from w  w w  . j av  a 2s  . c om
}

From source file:cito.server.AbstractEndpoint.java

/**
 * //from   w  ww.ja  v a2s.co  m
 * @param session
 * @param frame
 */
@OnMessage
public void message(Session session, Frame frame) {
    final String sessionId = session.getId();
    this.log.debug("Received message from client. [id={},principle={},command={}]", sessionId,
            session.getUserPrincipal(), frame.command());
    try (QuietClosable c = webSocketContext(this.beanManager).activate(session)) {
        final Message event = new Message(sessionId, frame);
        try (QuietClosable closable = ClientMessageProducer.set(event)) {
            this.relay.fromClient(event); // due to no @Observe @Priority we need to ensure the relay gets this first
            this.messageEvent.fire(event);
        }
    }
}

From source file:acromusashi.stream.hook.AmLogServerAdapter.java

/**
 * Websocket connection open./*from  w  ww . j av  a 2  s.co  m*/
 * 
 * @param session session
 */
public void onOpen(Session session) {
    this.sessions.put(session.getId(), session);
}

From source file:acromusashi.stream.hook.AmLogServerAdapter.java

/**
 * Websocket connection close./* ww w  . ja  v a 2  s .  c o m*/
 * 
 * @param session session
 */
public void onClose(Session session) {
    this.sessions.remove(session.getId());
}

From source file:SuperTenantSubscriptionEndpoint.java

@OnOpen
public void onOpen(Session session, @PathParam("adaptorname") String adaptorName) {
    if (log.isDebugEnabled()) {
        log.debug("WebSocket opened, for Session id: " + session.getId() + ", for the Adaptor:" + adaptorName);
    }//from w w  w  . ja v a2s . c  o  m
    tenantId = MultitenantConstants.SUPER_TENANT_ID;

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

From source file:SuperTenantDataReceiverEndpoint.java

@OnOpen
public void onOpen(Session session, @PathParam("adaptername") String adapterName) {
    if (log.isDebugEnabled()) {
        log.debug("WebSocket opened, for Session id: " + session.getId() + ", for the adapter:" + adapterName);
    }//from w  w w  .  j  av a 2 s.  c o m
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
    tenantId = carbonContext.getTenantId();
}

From source file:freddo.dtalk2.broker.servlet.DTalkServerEndpoint.java

@OnError
public void onError(Throwable exception, Session session) {
    LOG.error(">>> onError: (session: {})", session.getId(), exception);
    close();//  www.  ja v a 2s  .c  om
}

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());
    }//from  w w w  .j  a  v a 2 s . c  o m
}