mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: ParticipantRole to openvidu-java-client OpenViduRole
parent
cd347d6064
commit
77df02c8e9
|
@ -22,7 +22,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|||
import org.springframework.boot.info.BuildProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import io.openvidu.server.core.ParticipantRole;
|
||||
import io.openvidu.java.client.OpenViduRole;
|
||||
|
||||
@Component
|
||||
public class OpenviduConfig {
|
||||
|
@ -200,24 +200,23 @@ public class OpenviduConfig {
|
|||
return this.openviduRecordingNotification;
|
||||
}
|
||||
|
||||
public ParticipantRole[] getRolesFromRecordingNotification() {
|
||||
ParticipantRole[] roles;
|
||||
public OpenViduRole[] getRolesFromRecordingNotification() {
|
||||
OpenViduRole[] roles;
|
||||
switch (this.openviduRecordingNotification) {
|
||||
case "none":
|
||||
roles = new ParticipantRole[0];
|
||||
roles = new OpenViduRole[0];
|
||||
break;
|
||||
case "moderator":
|
||||
roles = new ParticipantRole[] { ParticipantRole.MODERATOR };
|
||||
roles = new OpenViduRole[] { OpenViduRole.MODERATOR };
|
||||
break;
|
||||
case "publisher_moderator":
|
||||
roles = new ParticipantRole[] { ParticipantRole.PUBLISHER, ParticipantRole.MODERATOR };
|
||||
roles = new OpenViduRole[] { OpenViduRole.PUBLISHER, OpenViduRole.MODERATOR };
|
||||
break;
|
||||
case "all":
|
||||
roles = new ParticipantRole[] { ParticipantRole.SUBSCRIBER, ParticipantRole.PUBLISHER,
|
||||
ParticipantRole.MODERATOR };
|
||||
roles = new OpenViduRole[] { OpenViduRole.SUBSCRIBER, OpenViduRole.PUBLISHER, OpenViduRole.MODERATOR };
|
||||
break;
|
||||
default:
|
||||
roles = new ParticipantRole[] { ParticipantRole.PUBLISHER, ParticipantRole.MODERATOR };
|
||||
roles = new OpenViduRole[] { OpenViduRole.PUBLISHER, OpenViduRole.MODERATOR };
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
/*
|
||||
* (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 ParticipantRole {
|
||||
SUBSCRIBER,
|
||||
PUBLISHER,
|
||||
MODERATOR;
|
||||
}
|
|
@ -36,6 +36,7 @@ import com.google.gson.JsonObject;
|
|||
import io.openvidu.client.OpenViduException;
|
||||
import io.openvidu.client.OpenViduException.Code;
|
||||
import io.openvidu.client.internal.ProtocolElements;
|
||||
import io.openvidu.java.client.OpenViduRole;
|
||||
import io.openvidu.server.cdr.CallDetailRecord;
|
||||
import io.openvidu.server.config.InfoHandler;
|
||||
import io.openvidu.server.config.OpenviduConfig;
|
||||
|
@ -552,13 +553,13 @@ public class SessionEventsHandler {
|
|||
return this.infoHandler;
|
||||
}
|
||||
|
||||
private Set<Participant> filterParticipantsByRole(ParticipantRole[] roles, Set<Participant> participants) {
|
||||
private Set<Participant> filterParticipantsByRole(OpenViduRole[] roles, Set<Participant> participants) {
|
||||
return participants.stream().filter(part -> {
|
||||
if (ProtocolElements.RECORDER_PARTICIPANT_PUBLICID.equals(part.getParticipantPublicId())) {
|
||||
return false;
|
||||
}
|
||||
boolean isRole = false;
|
||||
for (ParticipantRole role : roles) {
|
||||
for (OpenViduRole role : roles) {
|
||||
isRole = role.equals(part.getToken().getRole());
|
||||
if (isRole)
|
||||
break;
|
||||
|
|
|
@ -38,6 +38,7 @@ import com.google.gson.JsonObject;
|
|||
import io.openvidu.client.OpenViduException;
|
||||
import io.openvidu.client.OpenViduException.Code;
|
||||
import io.openvidu.client.internal.ProtocolElements;
|
||||
import io.openvidu.java.client.OpenViduRole;
|
||||
import io.openvidu.java.client.SessionProperties;
|
||||
import io.openvidu.server.OpenViduServer;
|
||||
import io.openvidu.server.cdr.CallDetailRecord;
|
||||
|
@ -225,7 +226,7 @@ public abstract class SessionManager {
|
|||
return sessionNotActive;
|
||||
}
|
||||
|
||||
public String newToken(String sessionId, ParticipantRole role, String serverMetadata,
|
||||
public String newToken(String sessionId, OpenViduRole role, String serverMetadata,
|
||||
KurentoTokenOptions kurentoTokenOptions) throws OpenViduException {
|
||||
|
||||
ConcurrentHashMap<String, Token> map = this.sessionidTokenTokenobj.putIfAbsent(sessionId,
|
||||
|
@ -273,7 +274,7 @@ public abstract class SessionManager {
|
|||
this.sessionidParticipantpublicidParticipant.putIfAbsent(sessionId, new ConcurrentHashMap<>());
|
||||
this.sessionidTokenTokenobj.putIfAbsent(sessionId, new ConcurrentHashMap<>());
|
||||
this.sessionidTokenTokenobj.get(sessionId).putIfAbsent(token,
|
||||
new Token(token, ParticipantRole.PUBLISHER, "",
|
||||
new Token(token, OpenViduRole.PUBLISHER, "",
|
||||
this.coturnCredentialsService.isCoturnAvailable()
|
||||
? this.coturnCredentialsService.createUser()
|
||||
: null,
|
||||
|
@ -285,8 +286,8 @@ public abstract class SessionManager {
|
|||
public boolean isPublisherInSession(String sessionId, Participant participant) {
|
||||
if (!this.isInsecureParticipant(participant.getParticipantPrivateId())) {
|
||||
if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) {
|
||||
return (ParticipantRole.PUBLISHER.equals(participant.getToken().getRole())
|
||||
|| ParticipantRole.MODERATOR.equals(participant.getToken().getRole()));
|
||||
return (OpenViduRole.PUBLISHER.equals(participant.getToken().getRole())
|
||||
|| OpenViduRole.MODERATOR.equals(participant.getToken().getRole()));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -298,7 +299,7 @@ public abstract class SessionManager {
|
|||
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());
|
||||
return OpenViduRole.MODERATOR.equals(participant.getToken().getRole());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -17,13 +17,14 @@
|
|||
|
||||
package io.openvidu.server.core;
|
||||
|
||||
import io.openvidu.java.client.OpenViduRole;
|
||||
import io.openvidu.server.coturn.TurnCredentials;
|
||||
import io.openvidu.server.kurento.core.KurentoTokenOptions;
|
||||
|
||||
public class Token {
|
||||
|
||||
private String token;
|
||||
private ParticipantRole role;
|
||||
private OpenViduRole role;
|
||||
private String serverMetadata = "";
|
||||
private TurnCredentials turnCredentials;
|
||||
|
||||
|
@ -33,7 +34,7 @@ public class Token {
|
|||
this.token = token;
|
||||
}
|
||||
|
||||
public Token(String token, ParticipantRole role, String serverMetadata, TurnCredentials turnCredentials,
|
||||
public Token(String token, OpenViduRole role, String serverMetadata, TurnCredentials turnCredentials,
|
||||
KurentoTokenOptions kurentoTokenOptions) {
|
||||
this.token = token;
|
||||
this.role = role;
|
||||
|
@ -46,7 +47,7 @@ public class Token {
|
|||
return token;
|
||||
}
|
||||
|
||||
public ParticipantRole getRole() {
|
||||
public OpenViduRole getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ import com.google.gson.JsonParser;
|
|||
import io.openvidu.client.OpenViduException;
|
||||
import io.openvidu.client.internal.ProtocolElements;
|
||||
import io.openvidu.java.client.MediaMode;
|
||||
import io.openvidu.java.client.OpenViduRole;
|
||||
import io.openvidu.java.client.Recording.OutputMode;
|
||||
import io.openvidu.java.client.RecordingLayout;
|
||||
import io.openvidu.java.client.RecordingMode;
|
||||
|
@ -50,7 +51,6 @@ import io.openvidu.java.client.RecordingProperties;
|
|||
import io.openvidu.java.client.SessionProperties;
|
||||
import io.openvidu.server.config.OpenviduConfig;
|
||||
import io.openvidu.server.core.Participant;
|
||||
import io.openvidu.server.core.ParticipantRole;
|
||||
import io.openvidu.server.core.Session;
|
||||
import io.openvidu.server.core.SessionManager;
|
||||
import io.openvidu.server.kurento.core.KurentoTokenOptions;
|
||||
|
@ -300,12 +300,12 @@ public class SessionRestController {
|
|||
}
|
||||
}
|
||||
|
||||
ParticipantRole role;
|
||||
OpenViduRole role;
|
||||
try {
|
||||
if (roleString != null) {
|
||||
role = ParticipantRole.valueOf(roleString);
|
||||
role = OpenViduRole.valueOf(roleString);
|
||||
} else {
|
||||
role = ParticipantRole.PUBLISHER;
|
||||
role = OpenViduRole.PUBLISHER;
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
return this.generateErrorResponse("Parameter role " + params.get("role") + " is not defined", "/api/tokens",
|
||||
|
|
Loading…
Reference in New Issue