Replace usages of SessionManager with usages of Utils, SessionStorage and SessionManagerProvider

pull/87/head
Thomas Joußen 2018-07-09 16:55:06 +02:00
parent 32329e1177
commit 798a7b7e64
4 changed files with 75 additions and 61 deletions

View File

@ -189,15 +189,7 @@ public abstract class SessionManager {
} }
public boolean isModeratorInSession(String sessionId, Participant participant) { public boolean isModeratorInSession(String sessionId, Participant participant) {
if (!this.isInsecureParticipant(participant.getParticipantPrivateId())) { return this.sessionStorage.isModeratorInSession(sessionId, participant);
if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) {
return ParticipantRole.MODERATOR.equals(participant.getToken().getRole());
} else {
return false;
}
} else {
return true;
}
} }
public boolean isInsecureParticipant(String participantPrivateId) { public boolean isInsecureParticipant(String participantPrivateId) {

View File

@ -308,4 +308,16 @@ public class SessionStorage {
public void showAllParticipants() { public void showAllParticipants() {
log.info("<SESSIONID, PARTICIPANTS>: {}", this.sessionidParticipantpublicidParticipant.toString()); log.info("<SESSIONID, PARTICIPANTS>: {}", this.sessionidParticipantpublicidParticipant.toString());
} }
public boolean isModeratorInSession(String sessionId, Participant participant) {
if (!this.isInsecureParticipant(participant.getParticipantPrivateId())) {
if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) {
return ParticipantRole.MODERATOR.equals(participant.getToken().getRole());
} else {
return false;
}
} else {
return true;
}
}
} }

View File

@ -57,11 +57,14 @@ import io.openvidu.server.recording.Recording;
public class SessionRestController { public class SessionRestController {
@Autowired @Autowired
private SessionManager sessionManager; private SessionManagerProvider sessionManagerProvider;
@Autowired @Autowired
private SessionStorage sessionStorage; private SessionStorage sessionStorage;
@Autowired
private Utils utils;
@Autowired @Autowired
private ComposedRecordingService recordingService; private ComposedRecordingService recordingService;
@ -125,11 +128,11 @@ public class SessionRestController {
} }
sessionId = customSessionId; sessionId = customSessionId;
} else { } else {
sessionId = sessionManager.generateRandomChain(); sessionId = utils.generateRandomChain();
this.sessionStorage.putTokenObject(sessionId, new ConcurrentHashMap<>()); this.sessionStorage.putTokenObject(sessionId, new ConcurrentHashMap<>());
} }
sessionManager.storeSessionId(sessionId, sessionProperties); sessionStorage.storeSessionId(sessionId, sessionProperties);
JSONObject responseJson = new JSONObject(); JSONObject responseJson = new JSONObject();
responseJson.put("id", sessionId); responseJson.put("id", sessionId);
@ -140,7 +143,7 @@ public class SessionRestController {
@RequestMapping(value = "/sessions/{sessionId}", method = RequestMethod.GET) @RequestMapping(value = "/sessions/{sessionId}", method = RequestMethod.GET)
public ResponseEntity<JSONObject> getSession(@PathVariable("sessionId") String sessionId, public ResponseEntity<JSONObject> getSession(@PathVariable("sessionId") String sessionId,
@RequestParam(value = "webRtcStats", defaultValue = "false", required = false) boolean webRtcStats) { @RequestParam(value = "webRtcStats", defaultValue = "false", required = false) boolean webRtcStats) {
Session session = this.sessionManager.getSession(sessionId); Session session = this.sessionStorage.getSession(sessionId);
if (session != null) { if (session != null) {
JSONObject response = (webRtcStats == true) ? session.withStatsToJSON() : session.toJSON(); JSONObject response = (webRtcStats == true) ? session.withStatsToJSON() : session.toJSON();
response.put("recording", this.recordingService.sessionIsBeingRecorded(sessionId)); response.put("recording", this.recordingService.sessionIsBeingRecorded(sessionId));
@ -154,7 +157,7 @@ public class SessionRestController {
@RequestMapping(value = "/sessions", method = RequestMethod.GET) @RequestMapping(value = "/sessions", method = RequestMethod.GET)
public ResponseEntity<JSONObject> listSessions( public ResponseEntity<JSONObject> listSessions(
@RequestParam(value = "webRtcStats", defaultValue = "false", required = false) boolean webRtcStats) { @RequestParam(value = "webRtcStats", defaultValue = "false", required = false) boolean webRtcStats) {
Collection<Session> sessions = this.sessionManager.getSessionObjects(); Collection<Session> sessions = this.sessionStorage.getSessionObjects();
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
JSONArray jsonArray = new JSONArray(); JSONArray jsonArray = new JSONArray();
sessions.forEach(s -> { sessions.forEach(s -> {
@ -169,9 +172,9 @@ public class SessionRestController {
@RequestMapping(value = "/sessions/{sessionId}", method = RequestMethod.DELETE) @RequestMapping(value = "/sessions/{sessionId}", method = RequestMethod.DELETE)
public ResponseEntity<JSONObject> closeSession(@PathVariable("sessionId") String sessionId) { public ResponseEntity<JSONObject> closeSession(@PathVariable("sessionId") String sessionId) {
Session session = this.sessionManager.getSession(sessionId); Session session = this.sessionStorage.getSession(sessionId);
if (session != null) { if (session != null) {
this.sessionManager.closeSession(sessionId, "sessionClosedByServer"); this.sessionManagerProvider.get(sessionId).closeSession(sessionId, "sessionClosedByServer");
return new ResponseEntity<>(HttpStatus.NO_CONTENT); return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} else { } else {
return new ResponseEntity<>(HttpStatus.NOT_FOUND); return new ResponseEntity<>(HttpStatus.NOT_FOUND);
@ -181,11 +184,11 @@ public class SessionRestController {
@RequestMapping(value = "/sessions/{sessionId}/connection/{connectionId}", method = RequestMethod.DELETE) @RequestMapping(value = "/sessions/{sessionId}/connection/{connectionId}", method = RequestMethod.DELETE)
public ResponseEntity<JSONObject> disconnectParticipant(@PathVariable("sessionId") String sessionId, public ResponseEntity<JSONObject> disconnectParticipant(@PathVariable("sessionId") String sessionId,
@PathVariable("connectionId") String participantPublicId) { @PathVariable("connectionId") String participantPublicId) {
Session session = this.sessionManager.getSession(sessionId); Session session = this.sessionStorage.getSession(sessionId);
if (session != null) { if (session != null) {
Participant participant = session.getParticipantByPublicId(participantPublicId); Participant participant = session.getParticipantByPublicId(participantPublicId);
if (participant != null) { if (participant != null) {
this.sessionManager.evictParticipant(participant, null, null, "forceDisconnectByServer"); this.sessionManagerProvider.get(sessionId).evictParticipant(participant, null, null, "forceDisconnectByServer");
return new ResponseEntity<>(HttpStatus.NO_CONTENT); return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} else { } else {
return new ResponseEntity<>(HttpStatus.NOT_FOUND); return new ResponseEntity<>(HttpStatus.NOT_FOUND);
@ -198,9 +201,9 @@ public class SessionRestController {
@RequestMapping(value = "/sessions/{sessionId}/stream/{streamId}", method = RequestMethod.DELETE) @RequestMapping(value = "/sessions/{sessionId}/stream/{streamId}", method = RequestMethod.DELETE)
public ResponseEntity<JSONObject> unpublishStream(@PathVariable("sessionId") String sessionId, public ResponseEntity<JSONObject> unpublishStream(@PathVariable("sessionId") String sessionId,
@PathVariable("streamId") String streamId) { @PathVariable("streamId") String streamId) {
Session session = this.sessionManager.getSession(sessionId); Session session = this.sessionStorage.getSession(sessionId);
if (session != null) { if (session != null) {
if (this.sessionManager.unpublishStream(session, streamId, null, null, "forceUnpublishByServer")) { if (this.sessionManagerProvider.get(sessionId).unpublishStream(session, streamId, null, null, "forceUnpublishByServer")) {
return new ResponseEntity<>(HttpStatus.NO_CONTENT); return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} else { } else {
return new ResponseEntity<>(HttpStatus.NOT_FOUND); return new ResponseEntity<>(HttpStatus.NOT_FOUND);
@ -236,7 +239,7 @@ public class SessionRestController {
metadata = (metadata != null) ? metadata : ""; metadata = (metadata != null) ? metadata : "";
String token = sessionManager.newToken(sessionId, role, metadata); String token = sessionStorage.newToken(sessionId, role, metadata);
JSONObject responseJson = new JSONObject(); JSONObject responseJson = new JSONObject();
responseJson.put("id", token); responseJson.put("id", token);
responseJson.put("session", sessionId); responseJson.put("session", sessionId);
@ -271,7 +274,7 @@ public class SessionRestController {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
} }
Session session = sessionManager.getSession(sessionId); Session session = sessionStorage.getSession(sessionId);
if (session == null) { if (session == null) {
// Session does not exist // Session does not exist
@ -327,11 +330,11 @@ public class SessionRestController {
return new ResponseEntity<>(HttpStatus.CONFLICT); return new ResponseEntity<>(HttpStatus.CONFLICT);
} }
Session session = sessionManager.getSession(recording.getSessionId()); Session session = sessionStorage.getSession(recording.getSessionId());
Recording stoppedRecording = this.recordingService.stopRecording(session); Recording stoppedRecording = this.recordingService.stopRecording(session);
sessionManager.evictParticipant( sessionManagerProvider.get(session.getSessionId()).evictParticipant(
session.getParticipantByPublicId(ProtocolElements.RECORDER_PARTICIPANT_PUBLICID), null, null, session.getParticipantByPublicId(ProtocolElements.RECORDER_PARTICIPANT_PUBLICID), null, null,
"EVICT_RECORDER"); "EVICT_RECORDER");

View File

@ -22,6 +22,8 @@ import java.util.List;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import io.openvidu.java.client.MediaMode;
import io.openvidu.server.core.*;
import org.kurento.jsonrpc.DefaultJsonRpcHandler; import org.kurento.jsonrpc.DefaultJsonRpcHandler;
import org.kurento.jsonrpc.Session; import org.kurento.jsonrpc.Session;
import org.kurento.jsonrpc.Transaction; import org.kurento.jsonrpc.Transaction;
@ -37,10 +39,6 @@ import io.openvidu.client.OpenViduException;
import io.openvidu.client.OpenViduException.Code; import io.openvidu.client.OpenViduException.Code;
import io.openvidu.client.internal.ProtocolElements; import io.openvidu.client.internal.ProtocolElements;
import io.openvidu.server.config.OpenviduConfig; import io.openvidu.server.config.OpenviduConfig;
import io.openvidu.server.core.MediaOptions;
import io.openvidu.server.core.Participant;
import io.openvidu.server.core.SessionManager;
import io.openvidu.server.core.Token;
public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> { public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
@ -48,9 +46,14 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
@Autowired @Autowired
OpenviduConfig openviduConfig; OpenviduConfig openviduConfig;
@Autowired
SessionManagerProvider sessionManagerProvider;
@Autowired @Autowired
SessionManager sessionManager; SessionStorage sessionStorage;
@Autowired
Utils utils;
@Autowired @Autowired
RpcNotificationService notificationService; RpcNotificationService notificationService;
@ -155,32 +158,33 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
boolean generateRecorderParticipant = false; boolean generateRecorderParticipant = false;
if (openviduConfig.isOpenViduSecret(secret)) { if (openviduConfig.isOpenViduSecret(secret)) {
sessionManager.newInsecureParticipant(participantPrivatetId); sessionStorage.newInsecureParticipant(participantPrivatetId);
token = sessionManager.generateRandomChain(); token = utils.generateRandomChain();
if (recorder) { if (recorder) {
generateRecorderParticipant = true; generateRecorderParticipant = true;
} }
} }
if (sessionManager.isTokenValidInSession(token, sessionId, participantPrivatetId)) { if (sessionStorage.isTokenValidInSession(token, sessionId, participantPrivatetId)) {
String clientMetadata = getStringParam(request, ProtocolElements.JOINROOM_METADATA_PARAM); String clientMetadata = getStringParam(request, ProtocolElements.JOINROOM_METADATA_PARAM);
if (sessionManager.isMetadataFormatCorrect(clientMetadata)) { if (utils.isMetadataFormatCorrect(clientMetadata)) {
Token tokenObj = sessionManager.consumeToken(sessionId, participantPrivatetId, token); Token tokenObj = sessionStorage.consumeToken(sessionId, participantPrivatetId, token);
Participant participant; Participant participant;
if (generateRecorderParticipant) { if (generateRecorderParticipant) {
participant = sessionManager.newRecorderParticipant(sessionId, participantPrivatetId, tokenObj, participant = sessionStorage.newRecorderParticipant(sessionId, participantPrivatetId, tokenObj,
clientMetadata); clientMetadata);
} else { } else {
participant = sessionManager.newParticipant(sessionId, participantPrivatetId, tokenObj, participant = sessionStorage.newParticipant(sessionId, participantPrivatetId, tokenObj,
clientMetadata); clientMetadata);
} }
rpcConnection.setSessionId(sessionId); rpcConnection.setSessionId(sessionId);
sessionManager.joinRoom(participant, sessionId, request.getId()); //@TODO The MediaMode should be transmitted on joinRoom action to support different MediaMode.
sessionManagerProvider.get(MediaMode.ROUTED).joinRoom(participant, sessionId, request.getId());
} else { } else {
log.error("ERROR: Metadata format set in client-side is incorrect"); log.error("ERROR: Metadata format set in client-side is incorrect");
@ -202,7 +206,7 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
return; return;
} }
sessionManager.leaveRoom(participant, request.getId(), "disconnect", true); sessionManagerProvider.get(rpcConnection.getSessionId()).leaveRoom(participant, request.getId(), "disconnect", true);
log.info("Participant {} has left session {}", participant.getParticipantPublicId(), log.info("Participant {} has left session {}", participant.getParticipantPublicId(),
rpcConnection.getSessionId()); rpcConnection.getSessionId());
} }
@ -215,9 +219,11 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
return; return;
} }
if (sessionManager.isPublisherInSession(rpcConnection.getSessionId(), participant)) { String sessionId = rpcConnection.getSessionId();
MediaOptions options = sessionManager.generateMediaOptions(request);
sessionManager.publishVideo(participant, options, request.getId()); if (sessionStorage.isPublisherInSession(sessionId, participant)) {
MediaOptions options = sessionManagerProvider.get(sessionId).generateMediaOptions(request);
sessionManagerProvider.get(sessionId).publishVideo(participant, options, request.getId());
} else { } else {
log.error("Error: participant {} is not a publisher", participant.getParticipantPublicId()); log.error("Error: participant {} is not a publisher", participant.getParticipantPublicId());
throw new OpenViduException(Code.USER_UNAUTHORIZED_ERROR_CODE, throw new OpenViduException(Code.USER_UNAUTHORIZED_ERROR_CODE,
@ -237,7 +243,7 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
senderName = senderName.substring(0, senderName.indexOf("_")); senderName = senderName.substring(0, senderName.indexOf("_"));
String sdpOffer = getStringParam(request, ProtocolElements.RECEIVEVIDEO_SDPOFFER_PARAM); String sdpOffer = getStringParam(request, ProtocolElements.RECEIVEVIDEO_SDPOFFER_PARAM);
sessionManager.subscribe(participant, senderName, sdpOffer, request.getId()); sessionManagerProvider.get(rpcConnection.getSessionId()).subscribe(participant, senderName, sdpOffer, request.getId());
} }
private void unsubscribeFromVideo(RpcConnection rpcConnection, Request<JsonObject> request) { private void unsubscribeFromVideo(RpcConnection rpcConnection, Request<JsonObject> request) {
@ -249,7 +255,7 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
} }
String senderName = getStringParam(request, ProtocolElements.UNSUBSCRIBEFROMVIDEO_SENDER_PARAM); String senderName = getStringParam(request, ProtocolElements.UNSUBSCRIBEFROMVIDEO_SENDER_PARAM);
sessionManager.unsubscribe(participant, senderName, request.getId()); sessionManagerProvider.get(rpcConnection.getSessionId()).unsubscribe(participant, senderName, request.getId());
} }
private void onIceCandidate(RpcConnection rpcConnection, Request<JsonObject> request) { private void onIceCandidate(RpcConnection rpcConnection, Request<JsonObject> request) {
@ -265,7 +271,7 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
String sdpMid = getStringParam(request, ProtocolElements.ONICECANDIDATE_SDPMIDPARAM); String sdpMid = getStringParam(request, ProtocolElements.ONICECANDIDATE_SDPMIDPARAM);
int sdpMLineIndex = getIntParam(request, ProtocolElements.ONICECANDIDATE_SDPMLINEINDEX_PARAM); int sdpMLineIndex = getIntParam(request, ProtocolElements.ONICECANDIDATE_SDPMLINEINDEX_PARAM);
sessionManager.onIceCandidate(participant, endpointName, candidate, sdpMLineIndex, sdpMid, request.getId()); sessionManagerProvider.get(rpcConnection.getSessionId()).onIceCandidate(participant, endpointName, candidate, sdpMLineIndex, sdpMid, request.getId());
} }
private void sendMessage(RpcConnection rpcConnection, Request<JsonObject> request) { private void sendMessage(RpcConnection rpcConnection, Request<JsonObject> request) {
@ -277,7 +283,7 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
} }
String message = getStringParam(request, ProtocolElements.SENDMESSAGE_MESSAGE_PARAM); String message = getStringParam(request, ProtocolElements.SENDMESSAGE_MESSAGE_PARAM);
sessionManager.sendMessage(participant, message, request.getId()); sessionManagerProvider.get(rpcConnection.getSessionId()).sendMessage(participant, message, request.getId());
} }
private void unpublishVideo(RpcConnection rpcConnection, Request<JsonObject> request) { private void unpublishVideo(RpcConnection rpcConnection, Request<JsonObject> request) {
@ -288,7 +294,7 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
return; return;
} }
sessionManager.unpublishVideo(participant, null, request.getId(), "unpublish"); sessionManagerProvider.get(rpcConnection.getSessionId()).unpublishVideo(participant, null, request.getId(), "unpublish");
} }
private void forceDisconnect(RpcConnection rpcConnection, Request<JsonObject> request) { private void forceDisconnect(RpcConnection rpcConnection, Request<JsonObject> request) {
@ -299,10 +305,10 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
return; return;
} }
if (sessionManager.isModeratorInSession(rpcConnection.getSessionId(), participant)) { if (sessionStorage.isModeratorInSession(rpcConnection.getSessionId(), participant)) {
String connectionId = getStringParam(request, ProtocolElements.FORCEDISCONNECT_CONNECTIONID_PARAM); String connectionId = getStringParam(request, ProtocolElements.FORCEDISCONNECT_CONNECTIONID_PARAM);
sessionManager.evictParticipant( sessionManagerProvider.get(rpcConnection.getSessionId()).evictParticipant(
sessionManager.getSession(rpcConnection.getSessionId()).getParticipantByPublicId(connectionId), sessionStorage.getSession(rpcConnection.getSessionId()).getParticipantByPublicId(connectionId),
participant, request.getId(), "forceDisconnectByUser"); participant, request.getId(), "forceDisconnectByUser");
} else { } else {
log.error("Error: participant {} is not a moderator", participant.getParticipantPublicId()); log.error("Error: participant {} is not a moderator", participant.getParticipantPublicId());
@ -319,9 +325,9 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
return; return;
} }
if (sessionManager.isModeratorInSession(rpcConnection.getSessionId(), participant)) { if (sessionStorage.isModeratorInSession(rpcConnection.getSessionId(), participant)) {
String streamId = getStringParam(request, ProtocolElements.FORCEUNPUBLISH_STREAMID_PARAM); String streamId = getStringParam(request, ProtocolElements.FORCEUNPUBLISH_STREAMID_PARAM);
sessionManager.unpublishStream(sessionManager.getSession(rpcConnection.getSessionId()), streamId, sessionManagerProvider.get(rpcConnection.getSessionId()).unpublishStream(sessionStorage.getSession(rpcConnection.getSessionId()), streamId,
participant, request.getId(), "forceUnpublishByUser"); participant, request.getId(), "forceUnpublishByUser");
} else { } else {
log.error("Error: participant {} is not a moderator", participant.getParticipantPublicId()); log.error("Error: participant {} is not a moderator", participant.getParticipantPublicId());
@ -344,12 +350,13 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
JsonElement newValue = getParam(request, ProtocolElements.STREAMPROPERTYCHANGED_NEWVALUE_PARAM); JsonElement newValue = getParam(request, ProtocolElements.STREAMPROPERTYCHANGED_NEWVALUE_PARAM);
String reason = getStringParam(request, ProtocolElements.STREAMPROPERTYCHANGED_REASON_PARAM); String reason = getStringParam(request, ProtocolElements.STREAMPROPERTYCHANGED_REASON_PARAM);
sessionManager.streamPropertyChanged(participant, request.getId(), streamId, property, newValue, reason); sessionManagerProvider.get(rpcConnection.getSessionId()).streamPropertyChanged(participant, request.getId(), streamId, property, newValue, reason);
} }
public void leaveRoomAfterConnClosed(String participantPrivateId, String reason) { public void leaveRoomAfterConnClosed(String sessionId, String participantPrivateId, String reason) {
try { try {
sessionManager.evictParticipant(this.sessionManager.getParticipant(participantPrivateId), null, null, SessionManager sessionManager = sessionManagerProvider.get(sessionId);
sessionManager.evictParticipant(sessionManager.getParticipant(participantPrivateId), null, null,
reason); reason);
log.info("Evicted participant with privateId {}", participantPrivateId); log.info("Evicted participant with privateId {}", participantPrivateId);
} catch (OpenViduException e) { } catch (OpenViduException e) {
@ -374,7 +381,7 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
message = "Evicting participant with private id {} because of a network disconnection"; message = "Evicting participant with private id {} because of a network disconnection";
} else if (status == null) { // && this.webSocketBrokenPipeTransportError.remove(rpcSessionId) != null)) { } else if (status == null) { // && this.webSocketBrokenPipeTransportError.remove(rpcSessionId) != null)) {
try { try {
Participant p = sessionManager.getParticipant(rpcSession.getSessionId()); Participant p = sessionStorage.getParticipant(rpcSession.getSessionId());
if (p != null) { if (p != null) {
message = "Evicting participant with private id {} because its websocket unexpectedly closed in the client side"; message = "Evicting participant with private id {} because its websocket unexpectedly closed in the client side";
} }
@ -385,10 +392,10 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
if (!message.isEmpty()) { if (!message.isEmpty()) {
RpcConnection rpc = this.notificationService.closeRpcSession(rpcSessionId); RpcConnection rpc = this.notificationService.closeRpcSession(rpcSessionId);
if (rpc != null && rpc.getSessionId() != null) { if (rpc != null && rpc.getSessionId() != null) {
io.openvidu.server.core.Session session = this.sessionManager.getSession(rpc.getSessionId()); io.openvidu.server.core.Session session = this.sessionStorage.getSession(rpc.getSessionId());
if (session != null && session.getParticipantByPrivateId(rpc.getParticipantPrivateId()) != null) { if (session != null && session.getParticipantByPrivateId(rpc.getParticipantPrivateId()) != null) {
log.info(message, rpc.getParticipantPrivateId()); log.info(message, rpc.getParticipantPrivateId());
leaveRoomAfterConnClosed(rpc.getParticipantPrivateId(), "networkDisconnect"); leaveRoomAfterConnClosed(rpcSessionId, rpc.getParticipantPrivateId(), "networkDisconnect");
} }
} }
} }
@ -397,7 +404,7 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
log.warn( log.warn(
"Evicting participant with private id {} because a transport error took place and its web socket connection is now closed", "Evicting participant with private id {} because a transport error took place and its web socket connection is now closed",
rpcSession.getSessionId()); rpcSession.getSessionId());
this.leaveRoomAfterConnClosed(rpcSessionId, "networkDisconnect"); this.leaveRoomAfterConnClosed(rpcSessionId, rpcSessionId, "networkDisconnect");
} }
} }
@ -467,11 +474,11 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
errorMsg = "No session information found for participant with privateId " + participantPrivateId errorMsg = "No session information found for participant with privateId " + participantPrivateId
+ ". Using the admin method to evict the user."; + ". Using the admin method to evict the user.";
log.warn(errorMsg); log.warn(errorMsg);
leaveRoomAfterConnClosed(participantPrivateId, ""); leaveRoomAfterConnClosed(sessionId, participantPrivateId, "");
throw new OpenViduException(Code.GENERIC_ERROR_CODE, errorMsg); throw new OpenViduException(Code.GENERIC_ERROR_CODE, errorMsg);
} else { } else {
// Sanity check: don't call RPC method unless the id checks out // Sanity check: don't call RPC method unless the id checks out
Participant participant = sessionManager.getParticipant(sessionId, participantPrivateId); Participant participant = sessionStorage.getParticipant(sessionId, participantPrivateId);
if (participant != null) { if (participant != null) {
errorMsg = "Participant " + participant.getParticipantPublicId() + " is calling method '" + methodName errorMsg = "Participant " + participant.getParticipantPublicId() + " is calling method '" + methodName
+ "' in session " + sessionId; + "' in session " + sessionId;
@ -481,7 +488,7 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
errorMsg = "Participant with private id " + participantPrivateId + " not found in session " + sessionId errorMsg = "Participant with private id " + participantPrivateId + " not found in session " + sessionId
+ ". Using the admin method to evict the user."; + ". Using the admin method to evict the user.";
log.warn(errorMsg); log.warn(errorMsg);
leaveRoomAfterConnClosed(participantPrivateId, ""); leaveRoomAfterConnClosed(sessionId, participantPrivateId, "");
throw new OpenViduException(Code.GENERIC_ERROR_CODE, errorMsg); throw new OpenViduException(Code.GENERIC_ERROR_CODE, errorMsg);
} }
} }