mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: refactoring reason to enum
parent
a43ccf7441
commit
f205827fbe
|
@ -19,17 +19,19 @@ package io.openvidu.server.cdr;
|
|||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import io.openvidu.server.core.EndReason;
|
||||
|
||||
public class CDREventEnd extends CDREvent {
|
||||
|
||||
protected Long startTime;
|
||||
protected Integer duration;
|
||||
protected String reason;
|
||||
protected EndReason reason;
|
||||
|
||||
public CDREventEnd(CDREventName eventName, String sessionId, Long timestamp) {
|
||||
super(eventName, sessionId, timestamp);
|
||||
}
|
||||
|
||||
public CDREventEnd(CDREventName eventName, String sessionId, Long startTime, String reason) {
|
||||
public CDREventEnd(CDREventName eventName, String sessionId, Long startTime, EndReason reason) {
|
||||
super(eventName, sessionId, System.currentTimeMillis());
|
||||
this.startTime = startTime;
|
||||
this.duration = (int) ((this.timeStamp - this.startTime) / 1000);
|
||||
|
@ -46,7 +48,7 @@ public class CDREventEnd extends CDREvent {
|
|||
json.addProperty("duration", this.duration);
|
||||
}
|
||||
if (this.reason != null) {
|
||||
json.addProperty("reason", this.reason);
|
||||
json.addProperty("reason", this.reason != null ? reason.name() : "");
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
@ -59,7 +61,7 @@ public class CDREventEnd extends CDREvent {
|
|||
return duration;
|
||||
}
|
||||
|
||||
public String getReason() {
|
||||
public EndReason getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ package io.openvidu.server.cdr;
|
|||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import io.openvidu.server.core.EndReason;
|
||||
import io.openvidu.server.core.Participant;
|
||||
|
||||
public class CDREventParticipant extends CDREventEnd {
|
||||
|
@ -32,7 +33,7 @@ public class CDREventParticipant extends CDREventEnd {
|
|||
}
|
||||
|
||||
// participantLeft
|
||||
public CDREventParticipant(CDREventParticipant event, String reason) {
|
||||
public CDREventParticipant(CDREventParticipant event, EndReason reason) {
|
||||
super(CDREventName.participantLeft, event.getSessionId(), event.getTimestamp(), reason);
|
||||
this.participant = event.participant;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ package io.openvidu.server.cdr;
|
|||
import com.google.gson.JsonObject;
|
||||
|
||||
import io.openvidu.java.client.RecordingLayout;
|
||||
import io.openvidu.server.core.EndReason;
|
||||
import io.openvidu.server.recording.Recording;
|
||||
|
||||
public class CDREventRecording extends CDREventEnd {
|
||||
|
@ -33,7 +34,7 @@ public class CDREventRecording extends CDREventEnd {
|
|||
}
|
||||
|
||||
// recordingStopped
|
||||
public CDREventRecording(CDREventRecording event, Recording recording, String reason) {
|
||||
public CDREventRecording(CDREventRecording event, Recording recording, EndReason reason) {
|
||||
super(CDREventName.recordingStopped, event.getSessionId(), event.getTimestamp(), reason);
|
||||
this.recording = recording;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package io.openvidu.server.cdr;
|
||||
|
||||
import io.openvidu.server.core.EndReason;
|
||||
import io.openvidu.server.core.Session;
|
||||
|
||||
public class CDREventSession extends CDREventEnd {
|
||||
|
@ -30,7 +31,7 @@ public class CDREventSession extends CDREventEnd {
|
|||
}
|
||||
|
||||
// sessionDestroyed
|
||||
public CDREventSession(CDREventSession event, String reason) {
|
||||
public CDREventSession(CDREventSession event, EndReason reason) {
|
||||
super(CDREventName.sessionDestroyed, event.getSessionId(), event.getTimestamp(), reason);
|
||||
this.session = event.session;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ package io.openvidu.server.cdr;
|
|||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import io.openvidu.server.core.EndReason;
|
||||
import io.openvidu.server.core.MediaOptions;
|
||||
import io.openvidu.server.core.Participant;
|
||||
|
||||
|
@ -40,7 +41,7 @@ public class CDREventWebrtcConnection extends CDREventEnd implements Comparable<
|
|||
}
|
||||
|
||||
// webrtcConnectionDestroyed
|
||||
public CDREventWebrtcConnection(CDREventWebrtcConnection event, String reason) {
|
||||
public CDREventWebrtcConnection(CDREventWebrtcConnection event, EndReason reason) {
|
||||
super(CDREventName.webrtcConnectionDestroyed, event.getSessionId(), event.getTimestamp(), reason);
|
||||
this.streamId = event.streamId;
|
||||
this.participant = event.participant;
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.concurrent.ConcurrentSkipListSet;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import io.openvidu.server.config.OpenviduConfig;
|
||||
import io.openvidu.server.core.EndReason;
|
||||
import io.openvidu.server.core.MediaOptions;
|
||||
import io.openvidu.server.core.Participant;
|
||||
import io.openvidu.server.core.Session;
|
||||
|
@ -113,7 +114,7 @@ public class CallDetailRecord {
|
|||
this.log(e);
|
||||
}
|
||||
|
||||
public void recordSessionDestroyed(String sessionId, String reason) {
|
||||
public void recordSessionDestroyed(String sessionId, EndReason reason) {
|
||||
CDREventSession e = this.sessions.remove(sessionId);
|
||||
if (e != null) {
|
||||
CDREventSession eventSessionEnd = new CDREventSession(e, RecordingManager.finalReason(reason));
|
||||
|
@ -131,7 +132,7 @@ public class CallDetailRecord {
|
|||
this.log(e);
|
||||
}
|
||||
|
||||
public void recordParticipantLeft(Participant participant, String sessionId, String reason) {
|
||||
public void recordParticipantLeft(Participant participant, String sessionId, EndReason reason) {
|
||||
CDREventParticipant e = this.participants.remove(participant.getParticipantPublicId());
|
||||
CDREventParticipant eventParticipantEnd = new CDREventParticipant(e, reason);
|
||||
this.log(eventParticipantEnd);
|
||||
|
@ -148,7 +149,7 @@ public class CallDetailRecord {
|
|||
this.log(publisher);
|
||||
}
|
||||
|
||||
public void stopPublisher(String participantPublicId, String streamId, String reason) {
|
||||
public void stopPublisher(String participantPublicId, String streamId, EndReason reason) {
|
||||
CDREventWebrtcConnection eventPublisherEnd = this.publications.remove(participantPublicId);
|
||||
if (eventPublisherEnd != null) {
|
||||
eventPublisherEnd = new CDREventWebrtcConnection(eventPublisherEnd, reason);
|
||||
|
@ -171,7 +172,7 @@ public class CallDetailRecord {
|
|||
this.log(subscriber);
|
||||
}
|
||||
|
||||
public void stopSubscriber(String participantPublicId, String senderPublicId, String streamId, String reason) {
|
||||
public void stopSubscriber(String participantPublicId, String senderPublicId, String streamId, EndReason reason) {
|
||||
Set<CDREventWebrtcConnection> participantSubscriptions = this.subscriptions.get(participantPublicId);
|
||||
if (participantSubscriptions != null) {
|
||||
CDREventWebrtcConnection eventSubscriberEnd;
|
||||
|
@ -197,7 +198,7 @@ public class CallDetailRecord {
|
|||
this.log(new CDREventRecording(sessionId, recording));
|
||||
}
|
||||
|
||||
public void recordRecordingStopped(String sessionId, Recording recording, String reason) {
|
||||
public void recordRecordingStopped(String sessionId, Recording recording, EndReason reason) {
|
||||
CDREventRecording recordingStartedEvent = this.recordings.remove(recording.getId());
|
||||
CDREventRecording recordingStoppedEvent = new CDREventRecording(recordingStartedEvent, recording,
|
||||
RecordingManager.finalReason(reason));
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* (C) Copyright 2017-2019 OpenVidu (https://openvidu.io/)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package io.openvidu.server.core;
|
||||
|
||||
public enum EndReason {
|
||||
|
||||
unsubscribe, unpublish, disconnect, forceUnpublishByUser, forceUnpublishByServer, forceDisconnectByUser,
|
||||
forceDisconnectByServer, lastParticipantLeft, networkDisconnect, mediaServerDisconnect, openviduServerStopped,
|
||||
recordingStoppedByServer, automaticStop, sessionClosedByServer
|
||||
|
||||
}
|
|
@ -167,11 +167,11 @@ public class Session implements SessionInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void leave(String participantPrivateId, String reason) {
|
||||
public void leave(String participantPrivateId, EndReason reason) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean close(String reason) {
|
||||
public boolean close(EndReason reason) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public class SessionEventsHandler {
|
|||
CDR.recordSessionCreated(session);
|
||||
}
|
||||
|
||||
public void onSessionClosed(String sessionId, String reason) {
|
||||
public void onSessionClosed(String sessionId, EndReason reason) {
|
||||
CDR.recordSessionDestroyed(sessionId, reason);
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ public class SessionEventsHandler {
|
|||
}
|
||||
|
||||
public void onParticipantLeft(Participant participant, String sessionId, Set<Participant> remainingParticipants,
|
||||
Integer transactionId, OpenViduException error, String reason) {
|
||||
Integer transactionId, OpenViduException error, EndReason reason) {
|
||||
if (error != null) {
|
||||
rpcNotificationService.sendErrorResponse(participant.getParticipantPrivateId(), transactionId, null, error);
|
||||
return;
|
||||
|
@ -174,7 +174,7 @@ public class SessionEventsHandler {
|
|||
|
||||
JsonObject params = new JsonObject();
|
||||
params.addProperty(ProtocolElements.PARTICIPANTLEFT_NAME_PARAM, participant.getParticipantPublicId());
|
||||
params.addProperty(ProtocolElements.PARTICIPANTLEFT_REASON_PARAM, reason);
|
||||
params.addProperty(ProtocolElements.PARTICIPANTLEFT_REASON_PARAM, reason != null ? reason.name() : "");
|
||||
|
||||
for (Participant p : remainingParticipants) {
|
||||
rpcNotificationService.sendNotification(p.getParticipantPrivateId(),
|
||||
|
@ -236,7 +236,7 @@ public class SessionEventsHandler {
|
|||
}
|
||||
|
||||
public void onUnpublishMedia(Participant participant, Set<Participant> participants, Participant moderator,
|
||||
Integer transactionId, OpenViduException error, String reason) {
|
||||
Integer transactionId, OpenViduException error, EndReason reason) {
|
||||
boolean isRpcFromModerator = transactionId != null && moderator != null;
|
||||
boolean isRpcFromOwner = transactionId != null && moderator == null;
|
||||
|
||||
|
@ -251,7 +251,7 @@ public class SessionEventsHandler {
|
|||
|
||||
JsonObject params = new JsonObject();
|
||||
params.addProperty(ProtocolElements.PARTICIPANTUNPUBLISHED_NAME_PARAM, participant.getParticipantPublicId());
|
||||
params.addProperty(ProtocolElements.PARTICIPANTUNPUBLISHED_REASON_PARAM, reason);
|
||||
params.addProperty(ProtocolElements.PARTICIPANTUNPUBLISHED_REASON_PARAM, reason != null ? reason.name() : "");
|
||||
|
||||
for (Participant p : participants) {
|
||||
if (p.getParticipantPrivateId().equals(participant.getParticipantPrivateId())) {
|
||||
|
@ -391,7 +391,7 @@ public class SessionEventsHandler {
|
|||
}
|
||||
|
||||
public void onForceDisconnect(Participant moderator, Participant evictedParticipant, Set<Participant> participants,
|
||||
Integer transactionId, OpenViduException error, String reason) {
|
||||
Integer transactionId, OpenViduException error, EndReason reason) {
|
||||
|
||||
boolean isRpcCall = transactionId != null;
|
||||
if (isRpcCall) {
|
||||
|
@ -406,7 +406,7 @@ public class SessionEventsHandler {
|
|||
JsonObject params = new JsonObject();
|
||||
params.addProperty(ProtocolElements.PARTICIPANTEVICTED_CONNECTIONID_PARAM,
|
||||
evictedParticipant.getParticipantPublicId());
|
||||
params.addProperty(ProtocolElements.PARTICIPANTEVICTED_REASON_PARAM, reason);
|
||||
params.addProperty(ProtocolElements.PARTICIPANTEVICTED_REASON_PARAM, reason != null ? reason.name() : "");
|
||||
|
||||
if (!ProtocolElements.RECORDER_PARTICIPANT_PUBLICID.equals(evictedParticipant.getParticipantPublicId())) {
|
||||
// Do not send a message when evicting RECORDER participant
|
||||
|
@ -439,7 +439,7 @@ public class SessionEventsHandler {
|
|||
}
|
||||
}
|
||||
|
||||
public void sendRecordingStoppedNotification(Session session, Recording recording, String reason) {
|
||||
public void sendRecordingStoppedNotification(Session session, Recording recording, EndReason reason) {
|
||||
|
||||
CDR.recordRecordingStopped(session.getSessionId(), recording, reason);
|
||||
|
||||
|
@ -462,7 +462,7 @@ public class SessionEventsHandler {
|
|||
JsonObject params = new JsonObject();
|
||||
params.addProperty(ProtocolElements.RECORDINGSTOPPED_ID_PARAM, recording.getId());
|
||||
params.addProperty(ProtocolElements.RECORDINGSTARTED_NAME_PARAM, recording.getName());
|
||||
params.addProperty(ProtocolElements.RECORDINGSTOPPED_REASON_PARAM, reason);
|
||||
params.addProperty(ProtocolElements.RECORDINGSTOPPED_REASON_PARAM, reason != null ? reason.name() : "");
|
||||
|
||||
for (Participant p : filteredParticipants) {
|
||||
rpcNotificationService.sendNotification(p.getParticipantPrivateId(),
|
||||
|
@ -472,7 +472,7 @@ public class SessionEventsHandler {
|
|||
|
||||
public void onFilterChanged(Participant participant, Participant moderator, Integer transactionId,
|
||||
Set<Participant> participants, String streamId, KurentoFilter filter, OpenViduException error,
|
||||
String reason) {
|
||||
String filterReason) {
|
||||
boolean isRpcFromModerator = transactionId != null && moderator != null;
|
||||
|
||||
if (isRpcFromModerator) {
|
||||
|
@ -500,7 +500,7 @@ public class SessionEventsHandler {
|
|||
}
|
||||
}
|
||||
params.add(ProtocolElements.STREAMPROPERTYCHANGED_NEWVALUE_PARAM, filterJson);
|
||||
params.addProperty(ProtocolElements.STREAMPROPERTYCHANGED_REASON_PARAM, reason);
|
||||
params.addProperty(ProtocolElements.STREAMPROPERTYCHANGED_REASON_PARAM, filterReason);
|
||||
|
||||
for (Participant p : participants) {
|
||||
if (p.getParticipantPrivateId().equals(participant.getParticipantPrivateId())) {
|
||||
|
|
|
@ -31,9 +31,9 @@ public interface SessionInterface {
|
|||
|
||||
void join(Participant participant);
|
||||
|
||||
void leave(String participantPrivateId, String reason);
|
||||
void leave(String participantPrivateId, EndReason reason);
|
||||
|
||||
boolean close(String reason);
|
||||
boolean close(EndReason reason);
|
||||
|
||||
boolean isClosed();
|
||||
|
||||
|
|
|
@ -84,13 +84,13 @@ public abstract class SessionManager {
|
|||
|
||||
public abstract void joinRoom(Participant participant, String sessionId, Integer transactionId);
|
||||
|
||||
public abstract void leaveRoom(Participant participant, Integer transactionId, String reason,
|
||||
public abstract void leaveRoom(Participant participant, Integer transactionId, EndReason reason,
|
||||
boolean closeWebSocket);
|
||||
|
||||
public abstract void publishVideo(Participant participant, MediaOptions mediaOptions, Integer transactionId);
|
||||
|
||||
public abstract void unpublishVideo(Participant participant, Participant moderator, Integer transactionId,
|
||||
String reason);
|
||||
EndReason reason);
|
||||
|
||||
public abstract void subscribe(Participant participant, String senderName, String sdpOffer, Integer transactionId);
|
||||
|
||||
|
@ -99,16 +99,16 @@ public abstract class SessionManager {
|
|||
public abstract void sendMessage(Participant participant, String message, Integer transactionId);
|
||||
|
||||
public abstract void streamPropertyChanged(Participant participant, Integer transactionId, String streamId,
|
||||
String property, JsonElement newValue, String reason);
|
||||
String property, JsonElement newValue, String changeReason);
|
||||
|
||||
public abstract void onIceCandidate(Participant participant, String endpointName, String candidate,
|
||||
int sdpMLineIndex, String sdpMid, Integer transactionId);
|
||||
|
||||
public abstract boolean unpublishStream(Session session, String streamId, Participant moderator,
|
||||
Integer transactionId, String reason);
|
||||
Integer transactionId, EndReason reason);
|
||||
|
||||
public abstract void evictParticipant(Participant evictedParticipant, Participant moderator, Integer transactionId,
|
||||
String reason);
|
||||
EndReason reason);
|
||||
|
||||
public abstract void applyFilter(Session session, String streamId, String filterType, JsonObject filterOptions,
|
||||
Participant moderator, Integer transactionId, String reason);
|
||||
|
@ -411,7 +411,7 @@ public abstract class SessionManager {
|
|||
log.info("Closing all sessions");
|
||||
for (String sessionId : sessions.keySet()) {
|
||||
try {
|
||||
closeSession(sessionId, "openviduServerStopped");
|
||||
closeSession(sessionId, EndReason.openviduServerStopped);
|
||||
} catch (Exception e) {
|
||||
log.warn("Error closing session '{}'", sessionId, e);
|
||||
}
|
||||
|
@ -433,7 +433,7 @@ public abstract class SessionManager {
|
|||
* @throws OpenViduException in case the session doesn't exist or has been
|
||||
* already closed
|
||||
*/
|
||||
public Set<Participant> closeSession(String sessionId, String reason) {
|
||||
public Set<Participant> closeSession(String sessionId, EndReason reason) {
|
||||
Session session = sessions.get(sessionId);
|
||||
if (session == null) {
|
||||
throw new OpenViduException(Code.ROOM_NOT_FOUND_ERROR_CODE, "Session '" + sessionId + "' not found");
|
||||
|
@ -456,7 +456,7 @@ public abstract class SessionManager {
|
|||
return participants;
|
||||
}
|
||||
|
||||
public void closeSessionAndEmptyCollections(Session session, String reason) {
|
||||
public void closeSessionAndEmptyCollections(Session session, EndReason reason) {
|
||||
|
||||
if (openviduConfig.isRecordingModuleEnabled()
|
||||
&& this.recordingManager.sessionIsBeingRecorded(session.getSessionId())) {
|
||||
|
|
|
@ -44,6 +44,7 @@ import io.openvidu.client.OpenViduException.Code;
|
|||
import io.openvidu.client.internal.ProtocolElements;
|
||||
import io.openvidu.java.client.OpenViduRole;
|
||||
import io.openvidu.server.config.OpenviduConfig;
|
||||
import io.openvidu.server.core.EndReason;
|
||||
import io.openvidu.server.core.MediaOptions;
|
||||
import io.openvidu.server.core.Participant;
|
||||
import io.openvidu.server.kurento.endpoint.MediaEndpoint;
|
||||
|
@ -186,7 +187,7 @@ public class KurentoParticipant extends Participant {
|
|||
return sdpResponse;
|
||||
}
|
||||
|
||||
public void unpublishMedia(String reason) {
|
||||
public void unpublishMedia(EndReason reason) {
|
||||
log.info("PARTICIPANT {}: unpublishing media stream from room {}", this.getParticipantPublicId(),
|
||||
this.session.getSessionId());
|
||||
releasePublisherEndpoint(reason);
|
||||
|
@ -279,12 +280,12 @@ public class KurentoParticipant extends Participant {
|
|||
log.error("Exception connecting subscriber endpoint " + "to publisher endpoint", e);
|
||||
}
|
||||
this.subscribers.remove(senderName);
|
||||
releaseSubscriberEndpoint(senderName, subscriber, "");
|
||||
releaseSubscriberEndpoint(senderName, subscriber, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void cancelReceivingMedia(String senderName, String reason) {
|
||||
public void cancelReceivingMedia(String senderName, EndReason reason) {
|
||||
log.info("PARTICIPANT {}: cancel receiving media from {}", this.getParticipantPublicId(), senderName);
|
||||
SubscriberEndpoint subscriberEndpoint = subscribers.remove(senderName);
|
||||
if (subscriberEndpoint == null || subscriberEndpoint.getEndpoint() == null) {
|
||||
|
@ -297,7 +298,7 @@ public class KurentoParticipant extends Participant {
|
|||
}
|
||||
}
|
||||
|
||||
public void close(String reason, boolean definitelyClosed) {
|
||||
public void close(EndReason reason, boolean definitelyClosed) {
|
||||
log.debug("PARTICIPANT {}: Closing user", this.getParticipantPublicId());
|
||||
if (isClosed()) {
|
||||
log.warn("PARTICIPANT {}: Already closed", this.getParticipantPublicId());
|
||||
|
@ -363,7 +364,7 @@ public class KurentoParticipant extends Participant {
|
|||
session.sendMediaError(this.getParticipantPrivateId(), desc);
|
||||
}
|
||||
|
||||
private void releasePublisherEndpoint(String reason) {
|
||||
private void releasePublisherEndpoint(EndReason reason) {
|
||||
if (publisher != null && publisher.getEndpoint() != null) {
|
||||
|
||||
// Remove streamId from publisher's map
|
||||
|
@ -395,7 +396,7 @@ public class KurentoParticipant extends Participant {
|
|||
}
|
||||
}
|
||||
|
||||
private void releaseSubscriberEndpoint(String senderName, SubscriberEndpoint subscriber, String reason) {
|
||||
private void releaseSubscriberEndpoint(String senderName, SubscriberEndpoint subscriber, EndReason reason) {
|
||||
if (subscriber != null) {
|
||||
|
||||
subscriber.unregisterErrorListeners();
|
||||
|
|
|
@ -35,6 +35,7 @@ import io.openvidu.client.OpenViduException.Code;
|
|||
import io.openvidu.client.internal.ProtocolElements;
|
||||
import io.openvidu.java.client.OpenViduRole;
|
||||
import io.openvidu.java.client.Recording.OutputMode;
|
||||
import io.openvidu.server.core.EndReason;
|
||||
import io.openvidu.server.core.Participant;
|
||||
import io.openvidu.server.core.Session;
|
||||
import io.openvidu.server.recording.Recording;
|
||||
|
@ -109,7 +110,7 @@ public class KurentoSession extends Session {
|
|||
participants.values(), participant.getParticipantPublicId());
|
||||
}
|
||||
|
||||
public void cancelPublisher(Participant participant, String reason) {
|
||||
public void cancelPublisher(Participant participant, EndReason reason) {
|
||||
// Cancel all subscribers for this publisher
|
||||
for (Participant subscriber : participants.values()) {
|
||||
if (participant.equals(subscriber)) {
|
||||
|
@ -124,7 +125,7 @@ public class KurentoSession extends Session {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void leave(String participantPrivateId, String reason) throws OpenViduException {
|
||||
public void leave(String participantPrivateId, EndReason reason) throws OpenViduException {
|
||||
|
||||
checkClosed();
|
||||
|
||||
|
@ -142,7 +143,7 @@ public class KurentoSession extends Session {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean close(String reason) {
|
||||
public boolean close(EndReason reason) {
|
||||
if (!closed) {
|
||||
|
||||
for (Participant participant : participants.values()) {
|
||||
|
@ -178,7 +179,7 @@ public class KurentoSession extends Session {
|
|||
this.kurentoSessionHandler.onMediaElementError(sessionId, participantId, description);
|
||||
}
|
||||
|
||||
private void removeParticipant(Participant participant, String reason) {
|
||||
private void removeParticipant(Participant participant, EndReason reason) {
|
||||
|
||||
checkClosed();
|
||||
|
||||
|
@ -285,11 +286,12 @@ public class KurentoSession extends Session {
|
|||
|
||||
// Stop recording if session is being recorded
|
||||
if (recordingManager.sessionIsBeingRecorded(this.sessionId)) {
|
||||
Recording stoppedRecording = this.recordingManager.forceStopRecording(this, "mediaServerDisconnect");
|
||||
Recording stoppedRecording = this.recordingManager.forceStopRecording(this,
|
||||
EndReason.mediaServerDisconnect);
|
||||
if (OutputMode.COMPOSED.equals(stoppedRecording.getOutputMode()) && stoppedRecording.hasVideo()) {
|
||||
recordingManager.getSessionManager().evictParticipant(
|
||||
this.getParticipantByPublicId(ProtocolElements.RECORDER_PARTICIPANT_PUBLICID), null, null,
|
||||
"EVICT_RECORDER");
|
||||
null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -298,10 +300,10 @@ public class KurentoSession extends Session {
|
|||
KurentoParticipant kParticipant = (KurentoParticipant) p;
|
||||
final boolean wasStreaming = kParticipant.isStreaming();
|
||||
kParticipant.releaseAllFilters();
|
||||
kParticipant.close("mediaServerDisconnect", false);
|
||||
kParticipant.close(EndReason.mediaServerDisconnect, false);
|
||||
if (wasStreaming) {
|
||||
kurentoSessionHandler.onUnpublishMedia(kParticipant, this.getParticipants(), null, null, null,
|
||||
"mediaServerDisconnect");
|
||||
EndReason.mediaServerDisconnect);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ import io.openvidu.java.client.RecordingLayout;
|
|||
import io.openvidu.java.client.RecordingMode;
|
||||
import io.openvidu.java.client.RecordingProperties;
|
||||
import io.openvidu.java.client.SessionProperties;
|
||||
import io.openvidu.server.core.EndReason;
|
||||
import io.openvidu.server.core.MediaOptions;
|
||||
import io.openvidu.server.core.Participant;
|
||||
import io.openvidu.server.core.Session;
|
||||
|
@ -122,7 +123,7 @@ public class KurentoSessionManager extends SessionManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public synchronized void leaveRoom(Participant participant, Integer transactionId, String reason,
|
||||
public synchronized void leaveRoom(Participant participant, Integer transactionId, EndReason reason,
|
||||
boolean closeWebSocket) {
|
||||
log.debug("Request [LEAVE_ROOM] ({})", participant.getParticipantPublicId());
|
||||
|
||||
|
@ -177,7 +178,7 @@ public class KurentoSessionManager extends SessionManager {
|
|||
sessionEventsHandler.onParticipantLeft(participant, sessionId, remainingParticipants, transactionId, null,
|
||||
reason);
|
||||
|
||||
if (!"sessionClosedByServer".equals(reason)) {
|
||||
if (!EndReason.sessionClosedByServer.equals(reason)) {
|
||||
// If session is closed by a call to "DELETE /api/sessions" do NOT stop the
|
||||
// recording. Will be stopped after in method
|
||||
// "SessionManager.closeSessionAndEmptyCollections"
|
||||
|
@ -330,7 +331,8 @@ public class KurentoSessionManager extends SessionManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void unpublishVideo(Participant participant, Participant moderator, Integer transactionId, String reason) {
|
||||
public void unpublishVideo(Participant participant, Participant moderator, Integer transactionId,
|
||||
EndReason reason) {
|
||||
try {
|
||||
KurentoParticipant kParticipant = (KurentoParticipant) participant;
|
||||
KurentoSession session = kParticipant.getSession();
|
||||
|
@ -355,7 +357,7 @@ public class KurentoSessionManager extends SessionManager {
|
|||
} catch (OpenViduException e) {
|
||||
log.warn("PARTICIPANT {}: Error unpublishing media", participant.getParticipantPublicId(), e);
|
||||
sessionEventsHandler.onUnpublishMedia(participant, new HashSet<>(Arrays.asList(participant)), moderator,
|
||||
transactionId, e, "");
|
||||
transactionId, e, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -420,7 +422,7 @@ public class KurentoSessionManager extends SessionManager {
|
|||
"User " + senderName + " not found in session " + session.getSessionId());
|
||||
}
|
||||
|
||||
kParticipant.cancelReceivingMedia(senderName, "unsubscribe");
|
||||
kParticipant.cancelReceivingMedia(senderName, EndReason.unsubscribe);
|
||||
|
||||
sessionEventsHandler.onUnsubscribe(participant, transactionId, null);
|
||||
}
|
||||
|
@ -526,7 +528,7 @@ public class KurentoSessionManager extends SessionManager {
|
|||
|
||||
@Override
|
||||
public void evictParticipant(Participant evictedParticipant, Participant moderator, Integer transactionId,
|
||||
String reason) throws OpenViduException {
|
||||
EndReason reason) throws OpenViduException {
|
||||
if (evictedParticipant != null) {
|
||||
KurentoParticipant kParticipant = (KurentoParticipant) evictedParticipant;
|
||||
Set<Participant> participants = kParticipant.getSession().getParticipants();
|
||||
|
@ -540,7 +542,7 @@ public class KurentoSessionManager extends SessionManager {
|
|||
new HashSet<>(Arrays.asList(moderator)), transactionId,
|
||||
new OpenViduException(Code.USER_NOT_FOUND_ERROR_CODE,
|
||||
"Connection not found when calling 'forceDisconnect'"),
|
||||
"");
|
||||
null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -602,7 +604,7 @@ public class KurentoSessionManager extends SessionManager {
|
|||
|
||||
@Override
|
||||
public boolean unpublishStream(Session session, String streamId, Participant moderator, Integer transactionId,
|
||||
String reason) {
|
||||
EndReason reason) {
|
||||
String participantPrivateId = ((KurentoSession) session).getParticipantPrivateIdFromStreamId(streamId);
|
||||
if (participantPrivateId != null) {
|
||||
Participant participant = this.getParticipant(participantPrivateId);
|
||||
|
@ -619,14 +621,14 @@ public class KurentoSessionManager extends SessionManager {
|
|||
|
||||
@Override
|
||||
public void applyFilter(Session session, String streamId, String filterType, JsonObject filterOptions,
|
||||
Participant moderator, Integer transactionId, String reason) {
|
||||
Participant moderator, Integer transactionId, String filterReason) {
|
||||
String participantPrivateId = ((KurentoSession) session).getParticipantPrivateIdFromStreamId(streamId);
|
||||
if (participantPrivateId != null) {
|
||||
Participant publisher = this.getParticipant(participantPrivateId);
|
||||
moderator = (moderator != null
|
||||
&& publisher.getParticipantPublicId().equals(moderator.getParticipantPublicId())) ? null
|
||||
: moderator;
|
||||
log.debug("Request [APPLY_FILTER] over stream [{}] for reason [{}]", streamId, reason);
|
||||
log.debug("Request [APPLY_FILTER] over stream [{}] for reason [{}]", streamId, filterReason);
|
||||
KurentoParticipant kParticipantPublisher = (KurentoParticipant) publisher;
|
||||
if (!publisher.isStreaming()) {
|
||||
log.warn(
|
||||
|
@ -652,7 +654,7 @@ public class KurentoSessionManager extends SessionManager {
|
|||
this.applyFilterInPublisher(kParticipantPublisher, filter);
|
||||
Set<Participant> participants = kParticipantPublisher.getSession().getParticipants();
|
||||
sessionEventsHandler.onFilterChanged(publisher, moderator, transactionId, participants, streamId,
|
||||
filter, null, reason);
|
||||
filter, null, filterReason);
|
||||
} catch (OpenViduException e) {
|
||||
log.warn("PARTICIPANT {}: Error applying filter", publisher.getParticipantPublicId(), e);
|
||||
sessionEventsHandler.onFilterChanged(publisher, moderator, transactionId, new HashSet<>(), streamId,
|
||||
|
@ -673,11 +675,11 @@ public class KurentoSessionManager extends SessionManager {
|
|||
|
||||
@Override
|
||||
public void removeFilter(Session session, String streamId, Participant moderator, Integer transactionId,
|
||||
String reason) {
|
||||
String filterReason) {
|
||||
String participantPrivateId = ((KurentoSession) session).getParticipantPrivateIdFromStreamId(streamId);
|
||||
if (participantPrivateId != null) {
|
||||
Participant participant = this.getParticipant(participantPrivateId);
|
||||
log.debug("Request [REMOVE_FILTER] over stream [{}] for reason [{}]", streamId, reason);
|
||||
log.debug("Request [REMOVE_FILTER] over stream [{}] for reason [{}]", streamId, filterReason);
|
||||
KurentoParticipant kParticipant = (KurentoParticipant) participant;
|
||||
if (!participant.isStreaming()) {
|
||||
log.warn(
|
||||
|
@ -701,7 +703,7 @@ public class KurentoSessionManager extends SessionManager {
|
|||
this.removeFilterInPublisher(kParticipant);
|
||||
Set<Participant> participants = kParticipant.getSession().getParticipants();
|
||||
sessionEventsHandler.onFilterChanged(participant, moderator, transactionId, participants, streamId,
|
||||
null, null, reason);
|
||||
null, null, filterReason);
|
||||
}
|
||||
|
||||
log.info("State of filter for participant {}: {}", kParticipant.getParticipantPublicId(),
|
||||
|
@ -717,11 +719,11 @@ public class KurentoSessionManager extends SessionManager {
|
|||
|
||||
@Override
|
||||
public void execFilterMethod(Session session, String streamId, String filterMethod, JsonObject filterParams,
|
||||
Participant moderator, Integer transactionId, String reason) {
|
||||
Participant moderator, Integer transactionId, String filterReason) {
|
||||
String participantPrivateId = ((KurentoSession) session).getParticipantPrivateIdFromStreamId(streamId);
|
||||
if (participantPrivateId != null) {
|
||||
Participant participant = this.getParticipant(participantPrivateId);
|
||||
log.debug("Request [EXEC_FILTER_MTEHOD] over stream [{}] for reason [{}]", streamId, reason);
|
||||
log.debug("Request [EXEC_FILTER_MTEHOD] over stream [{}] for reason [{}]", streamId, filterReason);
|
||||
KurentoParticipant kParticipant = (KurentoParticipant) participant;
|
||||
if (!participant.isStreaming()) {
|
||||
log.warn(
|
||||
|
@ -746,7 +748,7 @@ public class KurentoSessionManager extends SessionManager {
|
|||
filterParams);
|
||||
Set<Participant> participants = kParticipant.getSession().getParticipants();
|
||||
sessionEventsHandler.onFilterChanged(participant, moderator, transactionId, participants, streamId,
|
||||
updatedFilter, null, reason);
|
||||
updatedFilter, null, filterReason);
|
||||
}
|
||||
} else {
|
||||
log.warn("PARTICIPANT {}: Requesting to removeFilter to stream {} "
|
||||
|
|
|
@ -49,6 +49,7 @@ import io.openvidu.java.client.RecordingLayout;
|
|||
import io.openvidu.java.client.RecordingProperties;
|
||||
import io.openvidu.server.OpenViduServer;
|
||||
import io.openvidu.server.config.OpenviduConfig;
|
||||
import io.openvidu.server.core.EndReason;
|
||||
import io.openvidu.server.core.Participant;
|
||||
import io.openvidu.server.core.Session;
|
||||
import io.openvidu.server.kurento.core.KurentoParticipant;
|
||||
|
@ -99,11 +100,12 @@ public class ComposedRecordingService extends RecordingService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Recording stopRecording(Session session, Recording recording, String reason) {
|
||||
public Recording stopRecording(Session session, Recording recording, EndReason reason) {
|
||||
return this.stopRecording(session, recording, reason, false);
|
||||
}
|
||||
|
||||
public Recording stopRecording(Session session, Recording recording, String reason, boolean forceAfterKmsRestart) {
|
||||
public Recording stopRecording(Session session, Recording recording, EndReason reason,
|
||||
boolean forceAfterKmsRestart) {
|
||||
if (recording.hasVideo()) {
|
||||
return this.stopRecordingWithVideo(session, recording, reason);
|
||||
} else {
|
||||
|
@ -207,7 +209,7 @@ public class ComposedRecordingService extends RecordingService {
|
|||
return recording;
|
||||
}
|
||||
|
||||
private Recording stopRecordingWithVideo(Session session, Recording recording, String reason) {
|
||||
private Recording stopRecordingWithVideo(Session session, Recording recording, EndReason reason) {
|
||||
|
||||
log.info("Stopping composed ({}) recording {} of session {}. Reason: {}",
|
||||
recording.hasAudio() ? "video + audio" : "audio-only", recording.getId(), recording.getSessionId(),
|
||||
|
@ -334,7 +336,7 @@ public class ComposedRecordingService extends RecordingService {
|
|||
return recording;
|
||||
}
|
||||
|
||||
private Recording stopRecordingAudioOnly(Session session, Recording recording, String reason,
|
||||
private Recording stopRecordingAudioOnly(Session session, Recording recording, EndReason reason,
|
||||
boolean forceAfterKmsRestart) {
|
||||
|
||||
log.info("Stopping composed (audio-only) recording {} of session {}. Reason: {}", recording.getId(),
|
||||
|
|
|
@ -64,6 +64,7 @@ import io.openvidu.client.OpenViduException.Code;
|
|||
import io.openvidu.client.internal.ProtocolElements;
|
||||
import io.openvidu.java.client.RecordingProperties;
|
||||
import io.openvidu.server.config.OpenviduConfig;
|
||||
import io.openvidu.server.core.EndReason;
|
||||
import io.openvidu.server.core.Participant;
|
||||
import io.openvidu.server.core.Session;
|
||||
import io.openvidu.server.core.SessionEventsHandler;
|
||||
|
@ -107,8 +108,9 @@ public class RecordingManager {
|
|||
static final String IMAGE_NAME = "openvidu/openvidu-recording";
|
||||
static String IMAGE_TAG;
|
||||
|
||||
private static final List<String> LAST_PARTICIPANT_LEFT_REASONS = Arrays.asList(
|
||||
new String[] { "disconnect", "forceDisconnectByUser", "forceDisconnectByServer", "networkDisconnect" });
|
||||
private static final List<EndReason> LAST_PARTICIPANT_LEFT_REASONS = Arrays
|
||||
.asList(new EndReason[] { EndReason.disconnect, EndReason.forceDisconnectByUser,
|
||||
EndReason.forceDisconnectByServer, EndReason.networkDisconnect });
|
||||
|
||||
public SessionEventsHandler getSessionEventsHandler() {
|
||||
return this.sessionHandler;
|
||||
|
@ -192,7 +194,7 @@ public class RecordingManager {
|
|||
return recording;
|
||||
}
|
||||
|
||||
public Recording stopRecording(Session session, String recordingId, String reason) {
|
||||
public Recording stopRecording(Session session, String recordingId, EndReason reason) {
|
||||
Recording recording;
|
||||
if (session == null) {
|
||||
recording = this.startedRecordings.get(recordingId);
|
||||
|
@ -211,7 +213,7 @@ public class RecordingManager {
|
|||
return recording;
|
||||
}
|
||||
|
||||
public Recording forceStopRecording(Session session, String reason) {
|
||||
public Recording forceStopRecording(Session session, EndReason reason) {
|
||||
Recording recording;
|
||||
recording = this.sessionsRecordings.get(session.getSessionId());
|
||||
switch (recording.getOutputMode()) {
|
||||
|
@ -378,10 +380,10 @@ public class RecordingManager {
|
|||
// but never publishing (publishers automatically abort this thread)
|
||||
log.info("Closing session {} after automatic stop of recording {}", session.getSessionId(),
|
||||
recordingId);
|
||||
sessionManager.closeSessionAndEmptyCollections(session, "automaticStop");
|
||||
sessionManager.closeSessionAndEmptyCollections(session, EndReason.automaticStop);
|
||||
sessionManager.showTokens();
|
||||
} else {
|
||||
this.stopRecording(session, recordingId, "automaticStop");
|
||||
this.stopRecording(session, recordingId, EndReason.automaticStop);
|
||||
}
|
||||
} else {
|
||||
// This code is reachable if there already was an automatic stop of a recording
|
||||
|
@ -406,7 +408,7 @@ public class RecordingManager {
|
|||
log.info(
|
||||
"Ongoing recording of session {} was explicetly stopped within timeout for automatic recording stop. Closing session",
|
||||
session.getSessionId());
|
||||
sessionManager.closeSessionAndEmptyCollections(session, "automaticStop");
|
||||
sessionManager.closeSessionAndEmptyCollections(session, EndReason.automaticStop);
|
||||
sessionManager.showTokens();
|
||||
}
|
||||
return cancelled;
|
||||
|
@ -674,9 +676,9 @@ public class RecordingManager {
|
|||
log.info("Recording path successfully initialized at {}", openviduRecordingPath);
|
||||
}
|
||||
|
||||
public static String finalReason(String reason) {
|
||||
public static EndReason finalReason(EndReason reason) {
|
||||
if (RecordingManager.LAST_PARTICIPANT_LEFT_REASONS.contains(reason)) {
|
||||
return "lastParticipantLeft";
|
||||
return EndReason.lastParticipantLeft;
|
||||
} else {
|
||||
return reason;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import io.openvidu.client.OpenViduException.Code;
|
|||
import io.openvidu.java.client.RecordingLayout;
|
||||
import io.openvidu.java.client.RecordingProperties;
|
||||
import io.openvidu.server.config.OpenviduConfig;
|
||||
import io.openvidu.server.core.EndReason;
|
||||
import io.openvidu.server.core.Session;
|
||||
import io.openvidu.server.recording.Recording;
|
||||
import io.openvidu.server.utils.CommandExecutor;
|
||||
|
@ -47,7 +48,7 @@ public abstract class RecordingService {
|
|||
|
||||
public abstract Recording startRecording(Session session, RecordingProperties properties) throws OpenViduException;
|
||||
|
||||
public abstract Recording stopRecording(Session session, Recording recording, String reason);
|
||||
public abstract Recording stopRecording(Session session, Recording recording, EndReason reason);
|
||||
|
||||
/**
|
||||
* Generates metadata recording file (".recording.RECORDING_ID" JSON file to
|
||||
|
|
|
@ -52,6 +52,7 @@ import io.openvidu.client.OpenViduException;
|
|||
import io.openvidu.client.OpenViduException.Code;
|
||||
import io.openvidu.java.client.RecordingProperties;
|
||||
import io.openvidu.server.config.OpenviduConfig;
|
||||
import io.openvidu.server.core.EndReason;
|
||||
import io.openvidu.server.core.Participant;
|
||||
import io.openvidu.server.core.Session;
|
||||
import io.openvidu.server.kurento.core.KurentoParticipant;
|
||||
|
@ -127,11 +128,12 @@ public class SingleStreamRecordingService extends RecordingService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Recording stopRecording(Session session, Recording recording, String reason) {
|
||||
public Recording stopRecording(Session session, Recording recording, EndReason reason) {
|
||||
return this.stopRecording(session, recording, reason, false);
|
||||
}
|
||||
|
||||
public Recording stopRecording(Session session, Recording recording, String reason, boolean forceAfterKmsRestart) {
|
||||
public Recording stopRecording(Session session, Recording recording, EndReason reason,
|
||||
boolean forceAfterKmsRestart) {
|
||||
log.info("Stopping individual ({}) recording {} of session {}. Reason: {}",
|
||||
recording.hasVideo() ? (recording.hasAudio() ? "video+audio" : "video-only") : "audioOnly",
|
||||
recording.getId(), recording.getSessionId(), reason);
|
||||
|
|
|
@ -50,6 +50,7 @@ import io.openvidu.java.client.RecordingMode;
|
|||
import io.openvidu.java.client.RecordingProperties;
|
||||
import io.openvidu.java.client.SessionProperties;
|
||||
import io.openvidu.server.config.OpenviduConfig;
|
||||
import io.openvidu.server.core.EndReason;
|
||||
import io.openvidu.server.core.Participant;
|
||||
import io.openvidu.server.core.Session;
|
||||
import io.openvidu.server.core.SessionManager;
|
||||
|
@ -213,12 +214,12 @@ public class SessionRestController {
|
|||
|
||||
Session session = this.sessionManager.getSession(sessionId);
|
||||
if (session != null) {
|
||||
this.sessionManager.closeSession(sessionId, "sessionClosedByServer");
|
||||
this.sessionManager.closeSession(sessionId, EndReason.sessionClosedByServer);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
} else {
|
||||
Session sessionNotActive = this.sessionManager.getSessionNotActive(sessionId);
|
||||
if (sessionNotActive != null) {
|
||||
this.sessionManager.closeSessionAndEmptyCollections(sessionNotActive, "sessionClosedByServer");
|
||||
this.sessionManager.closeSessionAndEmptyCollections(sessionNotActive, EndReason.sessionClosedByServer);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
} else {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
|
@ -236,7 +237,7 @@ public class SessionRestController {
|
|||
if (session != null) {
|
||||
Participant participant = session.getParticipantByPublicId(participantPublicId);
|
||||
if (participant != null) {
|
||||
this.sessionManager.evictParticipant(participant, null, null, "forceDisconnectByServer");
|
||||
this.sessionManager.evictParticipant(participant, null, null, EndReason.forceDisconnectByServer);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
} else {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
|
@ -257,7 +258,7 @@ public class SessionRestController {
|
|||
|
||||
Session session = this.sessionManager.getSession(sessionId);
|
||||
if (session != null) {
|
||||
if (this.sessionManager.unpublishStream(session, streamId, null, null, "forceUnpublishByServer")) {
|
||||
if (this.sessionManager.unpublishStream(session, streamId, null, null, EndReason.forceUnpublishByServer)) {
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
} else {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
|
@ -524,14 +525,13 @@ public class SessionRestController {
|
|||
Session session = sessionManager.getSession(recording.getSessionId());
|
||||
|
||||
Recording stoppedRecording = this.recordingManager.stopRecording(session, recording.getId(),
|
||||
"recordingStoppedByServer");
|
||||
EndReason.recordingStoppedByServer);
|
||||
|
||||
session.recordingManuallyStopped.set(true);
|
||||
|
||||
if (session != null && OutputMode.COMPOSED.equals(recording.getOutputMode()) && recording.hasVideo()) {
|
||||
sessionManager.evictParticipant(
|
||||
session.getParticipantByPublicId(ProtocolElements.RECORDER_PARTICIPANT_PUBLICID), null, null,
|
||||
"EVICT_RECORDER");
|
||||
session.getParticipantByPublicId(ProtocolElements.RECORDER_PARTICIPANT_PUBLICID), null, null, null);
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(stoppedRecording.toJson().toString(), getResponseHeaders(), HttpStatus.OK);
|
||||
|
|
|
@ -45,6 +45,7 @@ import io.openvidu.client.OpenViduException;
|
|||
import io.openvidu.client.OpenViduException.Code;
|
||||
import io.openvidu.client.internal.ProtocolElements;
|
||||
import io.openvidu.server.config.OpenviduConfig;
|
||||
import io.openvidu.server.core.EndReason;
|
||||
import io.openvidu.server.core.MediaOptions;
|
||||
import io.openvidu.server.core.Participant;
|
||||
import io.openvidu.server.core.SessionManager;
|
||||
|
@ -277,7 +278,7 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
|
|||
return;
|
||||
}
|
||||
|
||||
sessionManager.leaveRoom(participant, request.getId(), "disconnect", true);
|
||||
sessionManager.leaveRoom(participant, request.getId(), EndReason.disconnect, true);
|
||||
log.info("Participant {} has left session {}", participant.getParticipantPublicId(),
|
||||
rpcConnection.getSessionId());
|
||||
}
|
||||
|
@ -363,7 +364,7 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
|
|||
return;
|
||||
}
|
||||
|
||||
sessionManager.unpublishVideo(participant, null, request.getId(), "unpublish");
|
||||
sessionManager.unpublishVideo(participant, null, request.getId(), EndReason.unpublish);
|
||||
}
|
||||
|
||||
private void streamPropertyChanged(RpcConnection rpcConnection, Request<JsonObject> request) {
|
||||
|
@ -394,7 +395,7 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
|
|||
String connectionId = getStringParam(request, ProtocolElements.FORCEDISCONNECT_CONNECTIONID_PARAM);
|
||||
sessionManager.evictParticipant(
|
||||
sessionManager.getSession(rpcConnection.getSessionId()).getParticipantByPublicId(connectionId),
|
||||
participant, request.getId(), "forceDisconnectByUser");
|
||||
participant, request.getId(), EndReason.forceDisconnectByUser);
|
||||
} else {
|
||||
log.error("Error: participant {} is not a moderator", participant.getParticipantPublicId());
|
||||
throw new OpenViduException(Code.USER_UNAUTHORIZED_ERROR_CODE,
|
||||
|
@ -413,7 +414,7 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
|
|||
if (sessionManager.isModeratorInSession(rpcConnection.getSessionId(), participant)) {
|
||||
String streamId = getStringParam(request, ProtocolElements.FORCEUNPUBLISH_STREAMID_PARAM);
|
||||
sessionManager.unpublishStream(sessionManager.getSession(rpcConnection.getSessionId()), streamId,
|
||||
participant, request.getId(), "forceUnpublishByUser");
|
||||
participant, request.getId(), EndReason.forceUnpublishByUser);
|
||||
} else {
|
||||
log.error("Error: participant {} is not a moderator", participant.getParticipantPublicId());
|
||||
throw new OpenViduException(Code.USER_UNAUTHORIZED_ERROR_CODE,
|
||||
|
@ -565,7 +566,7 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
|
|||
}
|
||||
}
|
||||
|
||||
public void leaveRoomAfterConnClosed(String participantPrivateId, String reason) {
|
||||
public void leaveRoomAfterConnClosed(String participantPrivateId, EndReason reason) {
|
||||
try {
|
||||
sessionManager.evictParticipant(this.sessionManager.getParticipant(participantPrivateId), null, null,
|
||||
reason);
|
||||
|
@ -620,7 +621,7 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
|
|||
io.openvidu.server.core.Session session = this.sessionManager.getSession(rpc.getSessionId());
|
||||
if (session != null && session.getParticipantByPrivateId(rpc.getParticipantPrivateId()) != null) {
|
||||
log.info(message, rpc.getParticipantPrivateId());
|
||||
leaveRoomAfterConnClosed(rpc.getParticipantPrivateId(), "networkDisconnect");
|
||||
leaveRoomAfterConnClosed(rpc.getParticipantPrivateId(), EndReason.networkDisconnect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -629,7 +630,7 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
|
|||
log.warn(
|
||||
"Evicting participant with private id {} because a transport error took place and its web socket connection is now closed",
|
||||
rpcSession.getSessionId());
|
||||
this.leaveRoomAfterConnClosed(rpcSessionId, "networkDisconnect");
|
||||
this.leaveRoomAfterConnClosed(rpcSessionId, EndReason.networkDisconnect);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -699,7 +700,7 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
|
|||
errorMsg = "No session information found for participant with privateId " + participantPrivateId
|
||||
+ ". Using the admin method to evict the user.";
|
||||
log.warn(errorMsg);
|
||||
leaveRoomAfterConnClosed(participantPrivateId, "");
|
||||
leaveRoomAfterConnClosed(participantPrivateId, null);
|
||||
throw new OpenViduException(Code.GENERIC_ERROR_CODE, errorMsg);
|
||||
} else {
|
||||
// Sanity check: don't call RPC method unless the id checks out
|
||||
|
@ -713,7 +714,7 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
|
|||
errorMsg = "Participant with private id " + participantPrivateId + " not found in session " + sessionId
|
||||
+ ". Using the admin method to evict the user.";
|
||||
log.warn(errorMsg);
|
||||
leaveRoomAfterConnClosed(participantPrivateId, "");
|
||||
leaveRoomAfterConnClosed(participantPrivateId, null);
|
||||
throw new OpenViduException(Code.GENERIC_ERROR_CODE, errorMsg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,8 @@ public class ParticipantSummary {
|
|||
long duration = (this.eventParticipantEnd.getTimestamp() - this.eventParticipantEnd.getStartTime()) / 1000;
|
||||
json.addProperty("duration", duration);
|
||||
|
||||
json.addProperty("reason", this.eventParticipantEnd.getReason());
|
||||
json.addProperty("reason",
|
||||
this.eventParticipantEnd.getReason().name() != null ? this.eventParticipantEnd.getReason().name() : "");
|
||||
|
||||
// Publishers summary
|
||||
JsonObject publishersJson = new JsonObject();
|
||||
|
|
|
@ -54,7 +54,8 @@ public class SessionSummary {
|
|||
long duration = (this.eventSessionEnd.getTimestamp() - this.eventSessionEnd.getStartTime()) / 1000;
|
||||
json.addProperty("duration", duration);
|
||||
|
||||
json.addProperty("reason", this.eventSessionEnd.getReason());
|
||||
json.addProperty("reason",
|
||||
this.eventSessionEnd.getReason() != null ? this.eventSessionEnd.getReason().name() : "");
|
||||
|
||||
// Final users
|
||||
JsonObject usersJson = new JsonObject();
|
||||
|
|
Loading…
Reference in New Issue