List of usage examples for org.springframework.web.socket WebSocketSession getId
String getId();
From source file:dk.apaq.orderly.CallHandler.java
private synchronized void stop(WebSocketSession session) throws IOException { String sessionId = session.getId(); if (presenterUserSession != null && presenterUserSession.getSession().getId().equals(sessionId)) { for (UserSession viewer : viewers.values()) { viewer.sendMessage(new BroadcastMessageResponse(BroadcastMessageType.StopCommunication)); }/*from w ww. j a va2 s . c o m*/ log.info("Releasing media pipeline"); if (pipeline != null) { pipeline.release(); } pipeline = null; presenterUserSession = null; } else if (viewers.containsKey(sessionId)) { if (viewers.get(sessionId).getWebRtcEndpoint() != null) { viewers.get(sessionId).getWebRtcEndpoint().release(); } viewers.remove(sessionId); } }
From source file:fi.vtt.nubomedia.armodule.BaseHandler.java
private void getStats(WebSocketSession session) { try {//from w w w .j a v a2 s .c o m UserSession user = users.get(session.getId()); if (user == null) { return; } Map<String, Stats> wr_stats = user.getWebRtcEndpoint().getStats(); //System.err.println("GET STATS..." + user.getWebRtcEndpoint().getStats()); System.err.println("GET STATS..." + wr_stats); for (Stats s : wr_stats.values()) { //for (Stats s : user.getWebRtcEndpoint().getStats().values()) { //System.err.println("STATS:" + s); switch (s.getType()) { case endpoint: //System.err.println("STATS endpoint"); EndpointStats end_stats = (EndpointStats) s; double e2eVideLatency = end_stats.getVideoE2ELatency() / 1000000; smart("***SMART E2E\t", e2eVideLatency, session.getId()); JsonObject response = new JsonObject(); response.addProperty("id", "videoE2Elatency"); response.addProperty("message", e2eVideLatency); sendMessage(session, new TextMessage(response.toString())); break; //case inboundrtp:{ //RTCInboundRTPStreamStats stats = (RTCInboundRTPStreamStats)s; //System.err.println(stats.getJitter()); //} //break; //case outboundrtp:{ //RTCOutboundRTPStreamStats stats = (RTCOutboundRTPStreamStats)s; // System.err.println(stats.getRoundTripTime()); // JsonObject response = new JsonObject(); // response.addProperty("id", "videoE2Elatency"); // response.addProperty("message", stats.getRoundTripTime()); // synchronized (session) { // session.sendMessage(new TextMessage(response.toString())); // } //} //break; default: //System.err.println("STATS DEFAULTS: " + s.getType() + "#" + s.getClass()); break; } } } catch (Throwable e) { log.error("Exception stats", e); } }
From source file:fi.vtt.nubomedia.armodule.BaseHandler.java
private void start(final WebSocketSession session, JsonObject jsonMessage) { try {/*from w w w . j a v a 2 s .c om*/ UserSession user = new UserSession(session.getId(), this); users.put(session.getId(), user); try { out = new PrintWriter("smart.txt"); } catch (Throwable t) { t.printStackTrace(); } String sdpOffer = jsonMessage.get("sdpOffer").getAsString(); String sdpAnswer = user.startSession(session, sdpOffer, jsonMessage); JsonObject response = new JsonObject(); response.addProperty("id", "startResponse"); response.addProperty("sdpAnswer", sdpAnswer); sendMessage(session, new TextMessage(response.toString())); } catch (Throwable t) { t.printStackTrace(); error(session, t.getMessage()); } }
From source file:com.visual_tools.nubomedia.nuboEarJava.NuboEarJavaHandler.java
private void release(WebSocketSession session) { UserSession user = users.remove(session.getId()); if (user != null) { user.release();//from ww w . j a v a 2 s. c om } }
From source file:fi.vtt.nubomedia.armodule.BaseHandler.java
public void sendMessage(WebSocketSession session, TextMessage message) { try {/*from w w w .j a v a2s. c o m*/ log.info("Sending message {} in session {}", message.getPayload(), session.getId()); synchronized (session) { session.sendMessage(message); } } catch (IOException e) { log.error("Exception sending message", e); } }
From source file:org.kurento.tutorial.player.PlayerFrameSaverHandler.java
public void sendPlayEnd(WebSocketSession session) { if (users.containsKey(session.getId())) { JsonObject response = new JsonObject(); response.addProperty("id", "playEnd"); sendMessage(session, response.toString()); }/*from w ww. j a v a 2s .c om*/ }
From source file:com.devicehive.websockets.handlers.DeviceHandlers.java
@PreAuthorize("isAuthenticated() and hasPermission(null, 'REGISTER_DEVICE')") public WebSocketResponse processDeviceSave(JsonObject request, WebSocketSession session) { String deviceId = request.get(Constants.DEVICE_ID).getAsString(); DeviceUpdate device = gson.fromJson(request.get(Constants.DEVICE), DeviceUpdate.class); logger.debug("device/save process started for session {}", session.getId()); if (deviceId == null) { throw new HiveException(Messages.DEVICE_GUID_REQUIRED, SC_BAD_REQUEST); }//from ww w . j a v a 2 s . co m device.setGuid(Optional.ofNullable(deviceId)); Set<DeviceClassEquipmentVO> equipmentSet = gson.fromJson(request.get(Constants.EQUIPMENT), new TypeToken<HashSet<DeviceClassEquipmentVO>>() { }.getType()); if (equipmentSet != null) { equipmentSet.remove(null); } deviceService.deviceSaveAndNotify(device, equipmentSet, (HivePrincipal) SecurityContextHolder.getContext().getAuthentication().getPrincipal()); logger.debug("device/save process ended for session {}", session.getId()); return new WebSocketResponse(); }
From source file:org.kurento.tutorial.one2onecall.CallHandler.java
public void stop(WebSocketSession session) throws IOException { String sessionId = session.getId(); if (pipelines.containsKey(sessionId)) { pipelines.get(sessionId).release(); CallMediaPipeline pipeline = pipelines.remove(sessionId); pipeline.release();//from w w w .j ava 2 s . c om // Both users can stop the communication. A 'stopCommunication' // message will be sent to the other peer. UserSession stopperUser = registry.getBySession(session); if (stopperUser != null) { UserSession stoppedUser = (stopperUser.getCallingFrom() != null) ? registry.getByName(stopperUser.getCallingFrom()) : stopperUser.getCallingTo() != null ? registry.getByName(stopperUser.getCallingTo()) : null; if (stoppedUser != null) { JsonObject message = new JsonObject(); message.addProperty("id", "stopCommunication"); stoppedUser.sendMessage(message); stoppedUser.clear(); } stopperUser.clear(); } } }
From source file:fi.vtt.nubomedia.armodule.BaseHandler.java
private void onIceCandidate(WebSocketSession session, JsonObject jsonMessage) { JsonObject jsonCandidate = jsonMessage.get("candidate").getAsJsonObject(); UserSession user = users.get(session.getId()); System.err.println("ME onIce: " + user); if (user != null) { user.addCandidate(jsonCandidate); }//from ww w.java2s. c o m }
From source file:org.kurento.tutorial.player.PlayerFrameSaverHandler.java
private void sendError(WebSocketSession session, String message) { if (users.containsKey(session.getId())) { JsonObject response = new JsonObject(); response.addProperty("id", "error"); response.addProperty("message", message); sendMessage(session, response.toString()); }/*from w ww . j a va 2 s.co m*/ }