List of usage examples for org.springframework.web.socket WebSocketSession getId
String getId();
From source file:org.kurento.tutorial.player.PlayerFrameSaverHandler.java
@Override public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception { stop(session.getId()); }
From source file:org.kurento.tutorial.player.PlayerFrameSaverHandler.java
private void getPosition(final WebSocketSession session) { UserSession user = users.get(session.getId()); if (user != null) { long position = user.getPlayerEndpoint().getPosition(); JsonObject response = new JsonObject(); response.addProperty("id", "position"); response.addProperty("position", position); sendMessage(session, response.toString()); }// www . j a v a 2 s .c o m }
From source file:fi.vtt.nubomedia.armodule.Ar3DHandler.java
private ArMarkerdetector getArFilter(WebSocketSession session) { UserSession user = users.get(session.getId()); if (user == null) { log.error("No UserSession found with the sessionId{}", session.getId()); return null; }// ww w.j av a 2 s . c o m ArMarkerdetector arFilter = (ArMarkerdetector) user.getUserData(); if (arFilter == null) { log.error("No ArFilter found with the sessionId{}", session.getId()); return null; } return arFilter; }
From source file:org.kurento.tutorial.player.PlayerFrameSaverHandler.java
private void resume(final WebSocketSession session) { UserSession user = users.get(session.getId()); if (user != null) { user.getPlayerEndpoint().play(); VideoInfo videoInfo = user.getPlayerEndpoint().getVideoInfo(); JsonObject response = new JsonObject(); response.addProperty("id", "videoInfo"); response.addProperty("isSeekable", videoInfo.getIsSeekable()); response.addProperty("initSeekable", videoInfo.getSeekableInit()); response.addProperty("endSeekable", videoInfo.getSeekableEnd()); response.addProperty("videoDuration", videoInfo.getDuration()); sendMessage(session, response.toString()); }/*from ww w .j a va 2s.com*/ }
From source file:com.visual_tools.nubomedia.nuboEarJava.NuboEarJavaHandler.java
@Override public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception { log.info("Closed websocket connection of session {}", session.getId()); release(session);/*from w ww .j av a2 s . c o m*/ }
From source file:org.kurento.tutorial.player.PlayerFrameSaverHandler.java
private void doSeek(final WebSocketSession session, JsonObject jsonMessage) { UserSession user = users.get(session.getId()); if (user != null) { try {/*from ww w.java 2s .c o m*/ user.getPlayerEndpoint().setPosition(jsonMessage.get("position").getAsLong()); } catch (KurentoException e) { log.debug("The seek cannot be performed"); JsonObject response = new JsonObject(); response.addProperty("id", "seek"); response.addProperty("message", "Seek failed"); sendMessage(session, response.toString()); } } }
From source file:com.visual_tools.nubomedia.nuboEarJava.NuboEarJavaHandler.java
private void start(final WebSocketSession session, JsonObject jsonMessage) { try {//from w ww. j a v a 2 s . c o m String sessionId = session.getId(); UserSession user = new UserSession(sessionId); users.put(sessionId, user); webRtcEndpoint = user.getWebRtcEndpoint(); //Ice Candidate webRtcEndpoint.addOnIceCandidateListener(new EventListener<OnIceCandidateEvent>() { @Override public void onEvent(OnIceCandidateEvent event) { JsonObject response = new JsonObject(); response.addProperty("id", "iceCandidate"); response.add("candidate", JsonUtils.toJsonObject(event.getCandidate())); sendMessage(session, new TextMessage(response.toString())); } }); /******** Media Logic ********/ ear = new NuboEarDetector.Builder(user.getMediaPipeline()).build(); webRtcEndpoint.connect(ear); ear.connect(webRtcEndpoint); ear.activateServerEvents(1, 3000); addEarListener(); // SDP negotiation (offer and answer) String sdpOffer = jsonMessage.get("sdpOffer").getAsString(); String sdpAnswer = webRtcEndpoint.processOffer(sdpOffer); // Sending response back to client JsonObject response = new JsonObject(); response.addProperty("id", "startResponse"); response.addProperty("sdpAnswer", sdpAnswer); synchronized (session) { sendMessage(session, new TextMessage(response.toString())); } webRtcEndpoint.gatherCandidates(); } catch (NotEnoughResourcesException e) { log.warn("Not enough resources", e); notEnoughResources(session); } catch (Throwable t) { log.error("Exception starting session", t); error(session, t.getClass().getSimpleName() + ": " + t.getMessage()); } }
From source file:com.music.web.websocket.GameHandler.java
private void join(String gameId, String playerName, WebSocketSession session) { Game game = games.get(gameId);//from ww w. ja v a2s . c o m if (game == null) { sendMessage(new GameEvent(GameEventType.NO_GAME_AVAILABLE), session); } if (!game.isStarted()) { String playerId = session.getId(); Player player = players.get(playerId); player.setName(playerName); playerGames.put(playerId, game); if (!game.playerJoined(player)) { sendMessage(new GameEvent(GameEventType.PLAYER_NAME_TAKEN), session); } } else { sendMessage(new GameEvent(GameEventType.GAME_ALREADY_STARTED), session); } }
From source file:com.kurento.kmf.jsonrpcconnector.internal.ws.JsonRpcWebSocketHandler.java
@Override public void afterConnectionClosed(WebSocketSession wsSession, org.springframework.web.socket.CloseStatus status) throws Exception { log.info("Connection closed because: " + status); if (!status.equals(CloseStatus.NORMAL)) { log.error("Abnormal termination"); } else {// w w w . java2 s . c om log.info("Normal termination"); } protocolManager.closeSessionIfTimeout(wsSession.getId(), status.getReason()); }
From source file:ch.rasc.wampspring.config.WampSubProtocolHandler.java
@Override public void afterSessionStarted(WebSocketSession session, MessageChannel outputChannel) { if (session.getTextMessageSizeLimit() < MINIMUM_WEBSOCKET_MESSAGE_SIZE) { session.setTextMessageSizeLimit(MINIMUM_WEBSOCKET_MESSAGE_SIZE); }//w ww. j av a 2 s .c o m WelcomeMessage welcomeMessage = new WelcomeMessage(session.getId(), SERVER_IDENTIFIER); try { session.sendMessage(new TextMessage(welcomeMessage.toJson(this.jsonFactory))); } catch (IOException e) { logger.error("Failed to send welcome message to client in session " + session.getId() + ".", e); } }