List of usage examples for javax.websocket Session getId
String getId();
From source file:org.wso2.carbon.device.mgt.analytics.wsproxy.inbound.SubscriptionEndpoint.java
/** * Web socket onClose - Remove the registered sessions * * @param session - Users registered session. * @param reason - Status code for web-socket close. * @param streamName - StreamName extracted from the ws url. * @param version - Version extracted from the ws url. * @param tenantDomain - Domain of the tenant. */// ww w .ja v a 2s . c o m public void onClose(Session session, CloseReason reason, String streamName, String version, String tenantDomain) { if (log.isDebugEnabled()) { log.debug("Closing a WebSocket due to " + reason.getReasonPhrase() + ", for session ID:" + session.getId() + ", for request URI - " + session.getRequestURI()); } for (AnalyticsClient analyticsClient : analyticsClientsMap.get(session.getId())) { if (analyticsClient != null) { try { analyticsClient.closeConnection(reason); } catch (WSProxyException e) { log.error("Error occurred while closing ws connection due to " + reason.getReasonPhrase() + ", for session ID:" + session.getId() + ", for request URI - " + session.getRequestURI(), e); } } } analyticsClientsMap.remove(session.getId()); }
From source file:org.wso2.carbon.device.mgt.analytics.wsproxy.inbound.SubscriptionEndpoint.java
/** * Web socket onMessage - When client sens a message * * @param session - Users registered session. * @param message - Status code for web-socket close. */// w ww. j a v a 2 s . c om void onMessage(Session session, String message) { for (AnalyticsClient analyticsClient : analyticsClientsMap.get(session.getId())) { if (analyticsClient != null) { analyticsClient.sendMessage(message); } } }
From source file:org.wso2.carbon.device.mgt.analytics.wsproxy.inbound.SubscriptionEndpoint.java
/** * Web socket onError//from w w w. j a v a2s .c om * * @param session - Users registered session. * @param throwable - Status code for web-socket close. * @param streamName - StreamName extracted from the ws url. * @param version - Version extracted from the ws url. * @param tenantDomain - Domain of the tenant. */ public void onError(Session session, Throwable throwable, String streamName, String version, String tenantDomain) { log.error("Error occurred in session ID: " + session.getId() + ", for request URI - " + session.getRequestURI() + ", " + throwable.getMessage(), throwable); }
From source file:org.wso2.carbon.device.mgt.analytics.wsproxy.inbound.SuperTenantSubscriptionEndpoint.java
/** * Web socket onOpen - When client sends a message * * @param session - Users registered session. * @param streamName - StreamName extracted from the ws url. * @param version - Version extracted from the ws url. *//*from ww w.j a v a2 s .c o m*/ @OnOpen public void onOpen(Session session, EndpointConfig config, @PathParam("streamname") String streamName, @PathParam("version") String version) { if (log.isDebugEnabled()) { log.debug("WebSocket opened, for Session id: " + session.getId() + ", for the Stream:" + streamName); } super.onOpen(session); }
From source file:org.wso2.carbon.device.mgt.analytics.wsproxy.inbound.SuperTenantSubscriptionEndpoint.java
/** * Web socket onMessage - When client sens a message * * @param session - Users registered session. * @param message - Status code for web-socket close. * @param streamName - StreamName extracted from the ws url. *///from w w w . ja v a 2s. co m @OnMessage public void onMessage(Session session, String message, @PathParam("streamname") String streamName) { if (log.isDebugEnabled()) { log.debug("Received message from client. Message: " + message + ", " + "for Session id: " + session.getId() + ", for the Stream:" + streamName); } super.onMessage(session, message); }
From source file:org.wso2.carbon.device.mgt.analytics.wsproxy.inbound.TenantSubscriptionEndpoint.java
/** * Web socket onOpen - When client sends a message * * @param session - Users registered session. * @param streamName - StreamName extracted from the ws url. * @param version - Version extracted from the ws url. * @param tdomain - Tenant domain extracted from ws url. *///from w w w. j a v a2 s . c o m @OnOpen public void onOpen(Session session, EndpointConfig config, @PathParam("streamname") String streamName, @PathParam("version") String version, @PathParam("tdomain") String tdomain) { if (log.isDebugEnabled()) { log.debug("WebSocket opened, for Session id: " + session.getId() + ", for the Stream:" + streamName); } super.onOpen(session); }
From source file:org.wso2.carbon.device.mgt.analytics.wsproxy.inbound.TenantSubscriptionEndpoint.java
/** * Web socket onMessage - When client sens a message * * @param session - Users registered session. * @param message - Status code for web-socket close. * @param streamName - StreamName extracted from the ws url. *///from w w w . j a va2s. co m @OnMessage public void onMessage(Session session, String message, @PathParam("streamname") String streamName, @PathParam("tdomain") String tdomain) { if (log.isDebugEnabled()) { log.debug("Received message from client. Message: " + message + ", for Session id: " + session.getId() + ", for tenant domain" + tdomain + ", for the Adaptor:" + streamName); } super.onMessage(session, message); }
From source file:org.wso2.carbon.device.mgt.analytics.wsproxy.outbound.AnalyticsClient.java
/** * Callback hook for Connection close events. * * @param userSession the analyticsSession which is getting closed. * @param reason the reason for connection close *///w ww. j av a 2 s . com @OnClose public void onClose(Session userSession, CloseReason reason) { if (log.isDebugEnabled()) { log.debug("Closing web socket session: '" + userSession.getId() + "'. Code: " + reason.getCloseCode().toString() + " Reason: " + reason.getReasonPhrase()); } }
From source file:org.wso2.carbon.device.mgt.extensions.remote.session.endpoint.SubscriptionEndpoint.java
/** * Web socket onMessage - When client sends a message * * @param session - Registered session. * @param deviceType - DeviceType/*from w ww . j a va2s .c o m*/ * @param message - String Message which needs to send to peer */ public void onMessage(Session session, String message, @PathParam("deviceType") String deviceType, @PathParam("deviceId") String deviceId) { if (log.isDebugEnabled()) { log.debug("Received message from client for RemoteSession id: " + session.getId() + " device type: " + deviceType + " device id: " + deviceId); } try { ServiceHolder.getInstance().getRemoteSessionManagementService().sendMessageToPeer(session, message); } catch (RemoteSessionManagementException e) { if (log.isDebugEnabled()) { log.error("Error occurred while send message to peer session ", e); } try { session.close(e.getCloseReason()); } catch (IOException ex) { if (log.isDebugEnabled()) { log.error("Failed to disconnect the client.", ex); } } } }
From source file:org.wso2.carbon.device.mgt.extensions.remote.session.endpoint.SubscriptionEndpoint.java
/** * Web socket onMessage use When client sends a message * * @param session - Registered session. * @param deviceType - DeviceType/*from www . j a v a 2s .co m*/ * @param deviceId - Device Identifier * @param message - Byte Message which needs to send to peer */ public void onMessage(Session session, byte[] message, @PathParam("deviceType") String deviceType, @PathParam("deviceId") String deviceId) { if (log.isDebugEnabled()) { log.debug("Received message from client for RemoteSession id: " + session.getId() + " device type: " + deviceType + " device id: " + deviceId); } try { ServiceHolder.getInstance().getRemoteSessionManagementService().sendMessageToPeer(session, message); } catch (RemoteSessionManagementException e) { if (log.isDebugEnabled()) { log.error("Error occurred while send message to peer session ", e); } try { session.close(e.getCloseReason()); } catch (IOException ex) { if (log.isDebugEnabled()) { log.error("Failed to disconnect the client.", ex); } } } }