private static String getChannel(Session session) { return session.getPathParameters().get(PARAM_CHANNEL); }
private static String getChannel(Session session) { return session.getPathParameters().get(PARAM_CHANNEL); }
private static String getChannel(Session session) { return session.getPathParameters().get(PARAM_CHANNEL); }
private static String getChannel(Session session) { return session.getPathParameters().get(PARAM_CHANNEL); }
private static String getChannel(Session session) { return session.getPathParameters().get(PARAM_CHANNEL); }
@Override public Object value(Session session, Object... values) throws DecodeException { Object result = null; if (decoder != null) { result = decoder.decode(session.getPathParameters().get(pathParamName)); } else if (type.equals(String.class)) { result = session.getPathParameters().get(pathParamName); } return result; } };
@Override public Object value(Session session, Object... values) throws DecodeException { Object result = null; if (decoder != null) { result = decoder.decode(session.getPathParameters().get(pathParamName)); } else if (type.equals(String.class)) { result = session.getPathParameters().get(pathParamName); } return result; } };
@Override public Object value(Session session, Object... values) throws DecodeException { Object result = null; if (decoder != null) { result = decoder.decode(session.getPathParameters().get(pathParamName)); } else if (type.equals(String.class)) { result = session.getPathParameters().get(pathParamName); } return result; } };
@Override public void onOpen(Session session, EndpointConfig config) { log.log(Level.FINER, "onOpen"); String sessionId = session.getPathParameters().get("session"); Map<String, List<String>> headers = SockJsServlet.retrieveHeaders(sessionId); SockJsRequest req = new SockJsWebsocketRequest(session, contextPath, prefix, headers); Transport.registerNoSession(req, server, new WebsocketReceiver(session)); }
@Override public void onOpen(Session session, EndpointConfig config) { factory.socketOpen(); Map<String,String> pathparms = session.getPathParameters(); String socketName = null; Exception err = null; if(pathparms.containsKey("socketName")){ try { socketName = (String)pathparms.get("socketName"); socket = factory.createSocket(socketName, session); HttpSession hs = (HttpSession) session.getUserProperties().get(HttpSession.class.getName()); if(hs!=null) { sessionMapper.accept(hs, session); } } catch (Exception e) { err = e; log.log(Level.SEVERE,"Error opening socket "+socketName,e); } } if(socket==null){ if(err==null){ log.warning("NO SOCKET FOUND "+socketName); } try { session.close(); } catch (IOException e) { log.log(Level.SEVERE, "Unable to close session for missing socket", e); } } }
@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); 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); } }
@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); 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); } }
String designId = session.getPathParameters().get("designId"); logger.debug("WebSocket opened: {}", session.getId()); logger.debug("\tdesignId: {}", designId);
String designId = session.getPathParameters().get("designId"); logger.debug("WebSocket opened: {}", session.getId()); logger.debug("\tdesignId: {}", designId);
@Override public void onClose(Session session, CloseReason closeReason) { // Get the channel and the channel id String channel = session.getPathParameters().get(PUSH_CHANNEL_PARAMETER); String channelToken = session.getQueryString(); Serializable user = (Serializable) session.getUserProperties().get(WebsocketConfigurator.WEBSOCKET_USER); // In this point in some cases (close reason 1006) CDI does not work and you cannot lookup application // scope beans, because the context could not be properly initialized. In that case we should try to // propagate the event but if an error happens, just ensure the Session is properly disposed. try { BeanManager beanManager = CDI.current().getBeanManager(); beanManager.fireEvent( new WebsocketEvent(channel, user, closeReason.getCloseCode()), CLOSED); } catch(Exception e) { //No op because it is expected something could go wrong. } finally { WebsocketApplicationSessionHolder.removeSession(channelToken); } }
String designId = session.getPathParameters().get("designId"); ApiDesignEditingSession editingSession = editingSessionManager.getEditingSession(designId); String msgType = message.get("type").asText();
Requests.getHeaders(), session.getRequestParameterMap(), session.getPathParameters(), session.getUserProperties(), new InetSocketAddress(Requests.getLocalName(), Requests.getLocalPort()),
String designId = session.getPathParameters().get("designId"); ApiDesignEditingSession editingSession = editingSessionManager.getEditingSession(designId); String msgType = message.get("type").asText();
String channel = session.getPathParameters().get(PUSH_CHANNEL_PARAMETER); String channelToken = session.getQueryString();