List of usage examples for javax.websocket Session getId
String getId();
From source file:freddo.dtalk2.broker.servlet.DTalkServerEndpoint.java
@OnOpen public void onOpen(Session session, EndpointConfig config) { LOG.trace(">>> onOpen: {}, userProperties: {}", session.getId(), config.getUserProperties()); mConfig = config;/*from w w w . j ava 2 s . c o m*/ mSession = session; if (LOG.isDebugEnabled()) { HandshakeRequest req = getHandshakeRequest(); HttpSession httpSession = (HttpSession) req.getHttpSession(); LOG.debug("================================="); LOG.debug("QueryString : {}", req.getQueryString()); LOG.debug("RequestURI : {}", req.getRequestURI()); LOG.debug("Headers : {}", req.getHeaders()); LOG.debug("UserPrincipal : {}", req.getUserPrincipal()); LOG.debug("ParameterMap : {}", req.getParameterMap()); LOG.debug("================================="); if (httpSession != null) { Enumeration<String> e = httpSession.getAttributeNames(); while (e.hasMoreElements()) { final String attr = e.nextElement(); LOG.debug("Session[{}]: {}", attr, httpSession.getAttribute(attr)); } LOG.debug("================================="); } } // TODO register connection & notify context listener }
From source file:SuperTenantTopicSubscriptionEndpoint.java
@OnMessage public void onMessage(Session session, String message, @PathParam("topic") String topic, @PathParam("adaptorname") String adaptorName) { if (log.isDebugEnabled()) { log.debug("Received: " + message + ", for Session id: " + session.getId() + ", for the Adaptor:" + adaptorName + ", for the Topic:" + topic); }// w w w. j a va2s . c o m }
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()); }//from www .java 2 s . co m try { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId); websocketLocalOutputCallbackRegisterService.unsubscribe(adaptorName, session); } finally { PrivilegedCarbonContext.endTenantFlow(); } }
From source file:hu.bme.iit.quiz.endpoint.PollEndpoint.java
private void joinRoom(Session session, Integer presentationID, String userkey) { userSessions.put(session.getId(), userkey); if (isQuizOwner(presentationID, session)) { quizzesInOngoingPhase.get(presentationID).setOwnerPeer(session); }//from w w w . java 2s.c o m quizzesInOngoingPhase.get(presentationID).addFollower(userkey); EndpointUtil.sendUpdateToAll(peers, createFollowersUpdateString(presentationID)); //If quiz is ongoing logger.debug("ActualQuestionAtJoin: " + quizzesInOngoingPhase.get(presentationID).getActualQuestion()); if (quizzesInOngoingPhase.get(presentationID).getActualQuestion() > -1) { EndpointUtil.sendUpdateToPeer(session, createQuizQuestionUpdateString(presentationID, quizzesInOngoingPhase.get(presentationID).getActualQuestion())); } }
From source file:SuperTenantSubscriptionEndpoint.java
@OnMessage public void onMessage(Session session, String message, @PathParam("adaptorname") String adaptorName) { if (log.isDebugEnabled()) { log.debug("Received and dropped message from client. Message: " + message + ", for Session id: " + session.getId() + ", for the Adaptor:" + adaptorName); }// ww w. j ava 2 s . c om }
From source file:TenantTopicSubscriptionEndpoint.java
@OnOpen public void onOpen(Session session, @PathParam("topic") String topic, @PathParam("adaptorname") String adaptorName, @PathParam("tdomain") String tdomain) { if (log.isDebugEnabled()) { log.debug("WebSocket opened, for Session id: " + session.getId() + ", for tenant domain" + tdomain + ", for the Adaptor:" + adaptorName + ", for the Topic:" + topic); }//from www . j a v a 2 s. c o m PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); carbonContext.setTenantDomain(tdomain, true); tenantId = carbonContext.getTenantId(); websocketLocalOutputCallbackRegisterService.subscribe(tenantId, adaptorName, topic, session); }
From source file:TenantDataReceiverEndpoint.java
@OnMessage public void onMessage(Session session, String message, @PathParam("tdomain") String tdomain, @PathParam("adaptername") String adapterName) { if (log.isDebugEnabled()) { log.debug("Received message: " + message + ", for session id: " + session.getId() + ", for tenant domain" + tdomain + ", for the adapter:" + adapterName); }//from www .j av a2 s .c om PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId); InputEventAdapterListener adapterListener = websocketLocalInputCallbackRegisterService .getAdapterListener(adapterName); if (adapterListener != null) { adapterListener.onEvent(message); } else { if (log.isDebugEnabled()) { log.debug("Dropping the message:" + message + " from session id: " + session.getId() + ", because no input websocket-local adapter exists" + "with name '" + adapterName + "', for tenant id: " + tenantId + ", and tenant domain: " + tdomain); } } PrivilegedCarbonContext.endTenantFlow(); }
From source file:hu.bme.iit.quiz.endpoint.PollEndpoint.java
@OnClose public void onClose(Session peer, @PathParam("presentationID") Integer presentationID) { logger.debug("onClose from client: " + peer.getId() + " presid: " + presentationID); quizzesInOngoingPhase.get(presentationID).removeFollower(userSessions.get(peer.getId())); userSessions.remove(peer.getId());// w w w . j a va 2s .com peers.remove(peer); EndpointUtil.sendUpdateToAll(peers, createFollowersUpdateString(presentationID)); }
From source file:TenantTopicSubscriptionEndpoint.java
@OnMessage public void onMessage(Session session, String message, @PathParam("topic") String topic, @PathParam("adaptorname") String adaptorName, @PathParam("tdomain") String tdomain) { if (log.isDebugEnabled()) { log.debug("Received: " + message + ", for Session id: " + session.getId() + ", for tenant domain" + tdomain + ", for the Adaptor:" + adaptorName + ", for the Topic:" + topic); }// ww w .j ava2 s .com }
From source file:eu.agilejava.snoop.scan.SnoopClient.java
/** * Sends message to the WebSocket server. * * @param endpoint The server endpoint/* w ww . java 2s .c o m*/ * @param msg The message * @return a return message */ private String sendMessage(String endpoint, String msg) { LOGGER.config(() -> "Sending message: " + msg); String returnValue = "-1"; try { WebSocketContainer container = ContainerProvider.getWebSocketContainer(); String uri = serviceUrl + endpoint; Session session = container.connectToServer(this, URI.create(uri)); session.getBasicRemote().sendText(msg != null ? msg : ""); returnValue = session.getId(); } catch (DeploymentException | IOException ex) { LOGGER.warning(ex.getMessage()); } return returnValue; }