String result = "";
if ("register".equalsIgnoreCase(cmdType)) {
if (sessions == null) {
sessions = new HashMap<String, WebRtcContentSession>();
MediaPipeline mp = session.getMediaPipelineFactory().create();
session.releaseOnTerminate(mp);
WebRtcEndpoint webRtcEndpoint = mp.newWebRtcEndpoint().build();
session.releaseOnTerminate(webRtcEndpoint);
session.setAttribute(WEBRTCKEY, webRtcEndpoint);
getLogger().info("**** {}", session.getSessionId());
sessions.put(session.getSessionId(), session);
result = "Waiting for another user in the room";
} else {
WebRtcEndpoint firstWebRtcEndpoint = (WebRtcEndpoint) sessions
.values().iterator().next().getAttribute(WEBRTCKEY);
MediaPipeline mp = firstWebRtcEndpoint.getMediaPipeline();
WebRtcEndpoint webRtcEndpoint = mp.newWebRtcEndpoint().build();
session.releaseOnTerminate(webRtcEndpoint);
webRtcEndpoint.connect(firstWebRtcEndpoint);
session.setAttribute(WEBRTCKEY, webRtcEndpoint);
getLogger().info("++++ {}", session.getSessionId());