openvidu-java-client: code structure closer to openvidu-node-client

pull/87/merge
pabloFuente 2018-07-22 22:20:21 +02:00
parent 42a4feb1d9
commit d2f7422b8f
8 changed files with 153 additions and 127 deletions

View File

@ -63,9 +63,9 @@ public class OpenVidu {
private static final Logger log = LoggerFactory.getLogger(OpenVidu.class);
private String urlOpenViduServer;
private String secret;
private HttpClient myHttpClient;
protected static String urlOpenViduServer;
protected static HttpClient httpClient;
protected static Map<String, Session> activeSessions = new ConcurrentHashMap<>();
protected final static String API_SESSIONS = "api/sessions";
@ -83,10 +83,10 @@ public class OpenVidu {
*/
public OpenVidu(String urlOpenViduServer, String secret) {
this.urlOpenViduServer = urlOpenViduServer;
OpenVidu.urlOpenViduServer = urlOpenViduServer;
if (!this.urlOpenViduServer.endsWith("/")) {
this.urlOpenViduServer += "/";
if (!OpenVidu.urlOpenViduServer.endsWith("/")) {
OpenVidu.urlOpenViduServer += "/";
}
this.secret = secret;
@ -114,7 +114,7 @@ public class OpenVidu {
requestBuilder = requestBuilder.setConnectTimeout(30000);
requestBuilder = requestBuilder.setConnectionRequestTimeout(30000);
this.myHttpClient = HttpClientBuilder.create().setDefaultRequestConfig(requestBuilder.build())
OpenVidu.httpClient = HttpClientBuilder.create().setDefaultRequestConfig(requestBuilder.build())
.setConnectionTimeToLive(30, TimeUnit.SECONDS).setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
.setSSLContext(sslContext).setDefaultCredentialsProvider(provider).build();
}
@ -128,7 +128,7 @@ public class OpenVidu {
* @throws OpenViduHttpException
*/
public Session createSession() throws OpenViduJavaClientException, OpenViduHttpException {
Session s = new Session(myHttpClient, urlOpenViduServer);
Session s = new Session();
OpenVidu.activeSessions.put(s.getSessionId(), s);
return s;
}
@ -153,7 +153,7 @@ public class OpenVidu {
*/
public Session createSession(SessionProperties properties)
throws OpenViduJavaClientException, OpenViduHttpException {
Session s = new Session(myHttpClient, urlOpenViduServer, properties);
Session s = new Session(properties);
OpenVidu.activeSessions.put(s.getSessionId(), s);
return s;
}
@ -189,7 +189,7 @@ public class OpenVidu {
public Recording startRecording(String sessionId, RecordingProperties properties)
throws OpenViduJavaClientException, OpenViduHttpException {
HttpPost request = new HttpPost(this.urlOpenViduServer + API_RECORDINGS + API_RECORDINGS_START);
HttpPost request = new HttpPost(OpenVidu.urlOpenViduServer + API_RECORDINGS + API_RECORDINGS_START);
JSONObject json = new JSONObject();
json.put("session", sessionId);
@ -208,7 +208,7 @@ public class OpenVidu {
HttpResponse response;
try {
response = myHttpClient.execute(request);
response = OpenVidu.httpClient.execute(request);
} catch (IOException e2) {
throw new OpenViduJavaClientException(e2.getMessage(), e2.getCause());
}
@ -216,7 +216,9 @@ public class OpenVidu {
try {
int statusCode = response.getStatusLine().getStatusCode();
if ((statusCode == org.apache.http.HttpStatus.SC_OK)) {
return new Recording(httpResponseToJson(response));
Recording r = new Recording(httpResponseToJson(response));
OpenVidu.activeSessions.get(r.getSessionId()).setIsBeingRecorded(true);
return r;
} else {
throw new OpenViduHttpException(statusCode);
}
@ -233,7 +235,9 @@ public class OpenVidu {
* @param name
* The name you want to give to the video file. You can access this
* same value in your clients on recording events (recordingStarted,
* recordingStopped)
* recordingStopped). <strong>WARNING: this parameter follows an
* overwriting policy.</strong> If you name two recordings the same,
* the newest MP4 file will overwrite the oldest one
*
* @return The started recording. If this method successfully returns the
* Recording object it means that the recording can be stopped with
@ -316,10 +320,10 @@ public class OpenVidu {
*/
public Recording stopRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException {
HttpPost request = new HttpPost(
this.urlOpenViduServer + API_RECORDINGS + API_RECORDINGS_STOP + "/" + recordingId);
OpenVidu.urlOpenViduServer + API_RECORDINGS + API_RECORDINGS_STOP + "/" + recordingId);
HttpResponse response;
try {
response = myHttpClient.execute(request);
response = OpenVidu.httpClient.execute(request);
} catch (IOException e) {
throw new OpenViduJavaClientException(e.getMessage(), e.getCause());
}
@ -327,7 +331,9 @@ public class OpenVidu {
try {
int statusCode = response.getStatusLine().getStatusCode();
if ((statusCode == org.apache.http.HttpStatus.SC_OK)) {
return new Recording(httpResponseToJson(response));
Recording r = new Recording(httpResponseToJson(response));
OpenVidu.activeSessions.get(r.getSessionId()).setIsBeingRecorded(false);
return r;
} else {
throw new OpenViduHttpException(statusCode);
}
@ -352,10 +358,10 @@ public class OpenVidu {
* </ul>
*/
public Recording getRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException {
HttpGet request = new HttpGet(this.urlOpenViduServer + API_RECORDINGS + "/" + recordingId);
HttpGet request = new HttpGet(OpenVidu.urlOpenViduServer + API_RECORDINGS + "/" + recordingId);
HttpResponse response;
try {
response = myHttpClient.execute(request);
response = OpenVidu.httpClient.execute(request);
} catch (IOException e) {
throw new OpenViduJavaClientException(e.getMessage(), e.getCause());
}
@ -382,10 +388,10 @@ public class OpenVidu {
*/
@SuppressWarnings("unchecked")
public List<Recording> listRecordings() throws OpenViduJavaClientException, OpenViduHttpException {
HttpGet request = new HttpGet(this.urlOpenViduServer + API_RECORDINGS);
HttpGet request = new HttpGet(OpenVidu.urlOpenViduServer + API_RECORDINGS);
HttpResponse response;
try {
response = myHttpClient.execute(request);
response = OpenVidu.httpClient.execute(request);
} catch (IOException e) {
throw new OpenViduJavaClientException(e.getMessage(), e.getCause());
}
@ -414,6 +420,7 @@ public class OpenVidu {
* {@link io.openvidu.java.client.Recording.Status#available}
*
* @param recordingId
* The id property of the recording you want to delete
*
* @throws OpenViduJavaClientException
* @throws OpenViduHttpException
@ -427,10 +434,10 @@ public class OpenVidu {
* </ul>
*/
public void deleteRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException {
HttpDelete request = new HttpDelete(this.urlOpenViduServer + API_RECORDINGS + "/" + recordingId);
HttpDelete request = new HttpDelete(OpenVidu.urlOpenViduServer + API_RECORDINGS + "/" + recordingId);
HttpResponse response;
try {
response = myHttpClient.execute(request);
response = OpenVidu.httpClient.execute(request);
} catch (IOException e) {
throw new OpenViduJavaClientException(e.getMessage(), e.getCause());
}
@ -461,6 +468,10 @@ public class OpenVidu {
* <li>Calling {@link io.openvidu.java.client.Session#forceUnpublish(Publisher)}
* also automatically updates the inner affected connections for that specific
* Session</li>
* <li>Calling {@link io.openvidu.java.client.OpenVidu#startRecording(String)}
* and {@link io.openvidu.java.client.OpenVidu#stopRecording(String)}
* automatically updates the recording status of the Session
* ({@link io.openvidu.java.client.Session#isBeingRecorded()})</li>
* </ul>
* <br>
* To get the list of active sessions with their current actual value, you must
@ -473,20 +484,24 @@ public class OpenVidu {
/**
* Updates every property of every active Session with the current status they
* have in OpenVidu Server. After calling this method you can acces the updated
* have in OpenVidu Server. After calling this method you can access the updated
* list of active sessions by calling
* {@link io.openvidu.java.client.OpenVidu#getActiveSessions()}
*
* @return true if any Session status has changed with respect to the server,
* false if not. This applies to any property or sub-property of any of
* the sessions locally stored in OpenVidu Java Client
*
* @throws OpenViduHttpException
* @throws OpenViduJavaClientException
*/
@SuppressWarnings("unchecked")
public boolean fetch() throws OpenViduJavaClientException, OpenViduHttpException {
HttpGet request = new HttpGet(this.urlOpenViduServer + API_SESSIONS);
HttpGet request = new HttpGet(OpenVidu.urlOpenViduServer + API_SESSIONS);
HttpResponse response;
try {
response = myHttpClient.execute(request);
response = OpenVidu.httpClient.execute(request);
} catch (IOException e) {
throw new OpenViduJavaClientException(e.getMessage(), e.getCause());
}
@ -500,7 +515,7 @@ public class OpenVidu {
// Set to store fetched sessionIds and later remove closed sessions
Set<String> fetchedSessionIds = new HashSet<>();
// Boolean to store if any Session has changed
boolean hasChanged = false;
final boolean[] hasChanged = { false };
jsonArraySessions.forEach(session -> {
String sessionId = (String) ((JSONObject) session).get("sessionId");
fetchedSessionIds.add(sessionId);
@ -508,12 +523,14 @@ public class OpenVidu {
String beforeJSON = s.toJson();
s = s.resetSessionWithJson((JSONObject) session);
String afterJSON = s.toJson();
log.info("Available session '{}' info fetched. Any change: {}", sessionId,
!beforeJSON.equals(afterJSON));
boolean changed = !beforeJSON.equals(afterJSON);
hasChanged[0] = hasChanged[0] || changed;
log.info("Available session '{}' info fetched. Any change: {}", sessionId, changed);
return s;
});
OpenVidu.activeSessions.computeIfAbsent(sessionId, sId -> {
log.info("New session '{}' fetched", sessionId);
hasChanged[0] = true;
return new Session((JSONObject) session);
});
});
@ -524,11 +541,12 @@ public class OpenVidu {
return true;
} else {
log.info("Removing closed session {}" + entry.getKey());
hasChanged[0] = true;
return false;
}
}).collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue()));
log.info("Active sessions info fetched: {}", OpenVidu.activeSessions.keySet());
return hasChanged;
return hasChanged[0];
} else {
throw new OpenViduHttpException(statusCode);
}

View File

@ -25,10 +25,13 @@ public class OpenViduHttpException extends Exception {
private static final long serialVersionUID = 1L;
private int status;
public OpenViduHttpException(int status) {
protected OpenViduHttpException(int status) {
super(Integer.toString(status));
}
/**
* @return The unexpected status of the HTTP request
*/
public int getStatus() {
return this.status;
}

View File

@ -24,11 +24,11 @@ public class OpenViduJavaClientException extends Exception {
private static final long serialVersionUID = 1L;
public OpenViduJavaClientException(String message) {
protected OpenViduJavaClientException(String message) {
super(message);
}
public OpenViduJavaClientException(String message, Throwable cause) {
protected OpenViduJavaClientException(String message, Throwable cause) {
super(message, cause);
}

View File

@ -20,89 +20,104 @@ package io.openvidu.java.client;
import org.json.simple.JSONObject;
/**
* See {@link io.openvidu.java.client.Connection#getPublishers()}
* See {@link io.openvidu.java.client.Connection#getPublishers()}.
*
* <br>
* This is a backend representation of a published media stream (see
* <a href="/api/openvidu-browser/classes/stream.html" target="_blank"> OpenVidu
* Browser Stream class</a>).
*/
public class Publisher {
class MediaOptions {
protected MediaOptions(boolean hasAudio, boolean hasVideo, Boolean audioActive, Boolean videoActive,
Integer frameRate, String typeOfVideo, String videoDimensions) {
this.hasAudio = hasAudio;
this.hasVideo = hasVideo;
this.audioActive = audioActive;
this.videoActive = videoActive;
this.frameRate = frameRate;
this.typeOfVideo = typeOfVideo;
this.videoDimensions = videoDimensions;
}
boolean hasVideo;
boolean hasAudio;
Boolean audioActive;
Boolean videoActive;
Integer frameRate;
String typeOfVideo;
String videoDimensions;
}
private String streamId;
private MediaOptions mediaOptions;
private boolean hasVideo;
private boolean hasAudio;
private Boolean audioActive;
private Boolean videoActive;
private Integer frameRate;
private String typeOfVideo;
private String videoDimensions;
public Publisher(String streamId, boolean hasAudio, boolean hasVideo, Object audioActive, Object videoActive,
protected Publisher(String streamId, boolean hasAudio, boolean hasVideo, Object audioActive, Object videoActive,
Object frameRate, Object typeOfVideo, Object videoDimensions) {
this.streamId = streamId;
Boolean audioActiveAux = null;
Boolean videoActiveAux = null;
Integer frameRateAux = null;
String typeOfVideoAux = null;
String videoDimensionsAux = null;
if (hasAudio) {
audioActiveAux = (boolean) audioActive;
this.hasAudio = hasAudio;
this.hasVideo = hasVideo;
this.audioActive = (Boolean) audioActive;
this.videoActive = (Boolean) videoActive;
if (frameRate != null) {
this.frameRate = ((Long) frameRate).intValue();
}
if (hasVideo) {
videoActiveAux = (boolean) videoActive;
if (frameRate != null) {
frameRateAux = ((Long) frameRate).intValue();
}
typeOfVideoAux = (String) typeOfVideo;
videoDimensionsAux = (String) videoDimensions;
}
this.mediaOptions = new MediaOptions(hasAudio, hasVideo, audioActiveAux, videoActiveAux, frameRateAux,
typeOfVideoAux, videoDimensionsAux);
this.typeOfVideo = (String) typeOfVideo;
this.videoDimensions = (String) videoDimensions;
}
/**
* Returns the unique identifier of the
* <a href="/api/openvidu-browser/classes/stream.html" target=
* "_blank">Stream</a> associated to this Publisher. Each Publisher is paired
* with only one Stream, so you can identify each Publisher by its
* <a href="/api/openvidu-browser/classes/stream.html#streamid" target=
* "_blank"><code>Stream.streamId</code></a>
*/
public String getStreamId() {
return streamId;
}
/**
* See properties of <a href="/api/openvidu-browser/classes/stream.html" target=
* "_blank">Stream</a> object in OpenVidu Browser library to find out more
*/
public boolean hasVideo() {
return this.mediaOptions.hasVideo;
return this.hasVideo;
}
/**
* See properties of <a href="/api/openvidu-browser/classes/stream.html" target=
* "_blank">Stream</a> object in OpenVidu Browser library to find out more
*/
public boolean hasAudio() {
return this.mediaOptions.hasAudio;
return this.hasAudio;
}
/**
* See properties of <a href="/api/openvidu-browser/classes/stream.html" target=
* "_blank">Stream</a> object in OpenVidu Browser library to find out more
*/
public Boolean isAudioActive() {
return this.mediaOptions.audioActive;
return this.audioActive;
}
/**
* See properties of <a href="/api/openvidu-browser/classes/stream.html" target=
* "_blank">Stream</a> object in OpenVidu Browser library to find out more
*/
public Boolean isVideoActive() {
return this.mediaOptions.videoActive;
return this.videoActive;
}
/**
* See properties of <a href="/api/openvidu-browser/classes/stream.html" target=
* "_blank">Stream</a> object in OpenVidu Browser library to find out more
*/
public Integer getFrameRate() {
return this.mediaOptions.frameRate;
return this.frameRate;
}
/**
* See properties of <a href="/api/openvidu-browser/classes/stream.html" target=
* "_blank">Stream</a> object in OpenVidu Browser library to find out more
*/
public String getTypeOfVideo() {
return this.mediaOptions.typeOfVideo;
return this.typeOfVideo;
}
/**
* See properties of <a href="/api/openvidu-browser/classes/stream.html" target=
* "_blank">Stream</a> object in OpenVidu Browser library to find out more
*/
public String getVideoDimensions() {
return this.mediaOptions.videoDimensions;
return this.videoDimensions;
}
@SuppressWarnings("unchecked")

View File

@ -71,7 +71,7 @@ public class Recording {
private boolean hasVideo = true;
private RecordingProperties recordingProperties;
public Recording(JSONObject json) {
protected Recording(JSONObject json) {
this.id = (String) json.get("id");
this.sessionId = (String) json.get("sessionId");
this.createdAt = (long) json.get("createdAt");

View File

@ -46,7 +46,9 @@ public class RecordingProperties {
/**
* Call this method to set the name of the video file. You can access this same
* value in your clients on recording events (<code>recordingStarted</code>,
* <code>recordingStopped</code>)
* <code>recordingStopped</code>). <strong>WARNING: this parameter follows an
* overwriting policy.</strong> If you name two recordings the same, the newest
* MP4 file will overwrite the oldest one
*/
public RecordingProperties.Builder name(String name) {
this.name = name;
@ -86,7 +88,9 @@ public class RecordingProperties {
/**
* Defines the name you want to give to the video file. You can access this same
* value in your clients on recording events (<code>recordingStarted</code>,
* <code>recordingStopped</code>)
* <code>recordingStopped</code>). <strong>WARNING: this parameter follows an
* overwriting policy.</strong> If you name two recordings the same, the newest
* MP4 file will overwrite the oldest one
*/
public String name() {
return this.name;

View File

@ -27,7 +27,6 @@ import java.util.stream.Collectors;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
@ -44,25 +43,17 @@ public class Session {
private static final Logger log = LoggerFactory.getLogger(Session.class);
private HttpClient httpClient;
private String urlOpenViduServer;
private String sessionId;
private SessionProperties properties;
private Map<String, Connection> activeConnections = new ConcurrentHashMap<>();
private boolean recording = false;
protected Session(HttpClient httpClient, String urlOpenViduServer)
throws OpenViduJavaClientException, OpenViduHttpException {
this.httpClient = httpClient;
this.urlOpenViduServer = urlOpenViduServer;
protected Session() throws OpenViduJavaClientException, OpenViduHttpException {
this.properties = new SessionProperties.Builder().build();
this.getSessionIdHttp();
}
protected Session(HttpClient httpClient, String urlOpenViduServer, SessionProperties properties)
throws OpenViduJavaClientException, OpenViduHttpException {
this.httpClient = httpClient;
this.urlOpenViduServer = urlOpenViduServer;
protected Session(SessionProperties properties) throws OpenViduJavaClientException, OpenViduHttpException {
this.properties = properties;
this.getSessionIdHttp();
}
@ -111,7 +102,7 @@ public class Session {
this.getSessionId();
}
HttpPost request = new HttpPost(this.urlOpenViduServer + OpenVidu.API_TOKENS);
HttpPost request = new HttpPost(OpenVidu.urlOpenViduServer + OpenVidu.API_TOKENS);
JSONObject json = new JSONObject();
json.put("session", this.sessionId);
@ -129,7 +120,7 @@ public class Session {
HttpResponse response;
try {
response = httpClient.execute(request);
response = OpenVidu.httpClient.execute(request);
} catch (IOException e2) {
throw new OpenViduJavaClientException(e2.getMessage(), e2.getCause());
}
@ -156,12 +147,12 @@ public class Session {
* @throws OpenViduHttpException
*/
public void close() throws OpenViduJavaClientException, OpenViduHttpException {
HttpDelete request = new HttpDelete(this.urlOpenViduServer + OpenVidu.API_SESSIONS + "/" + this.sessionId);
HttpDelete request = new HttpDelete(OpenVidu.urlOpenViduServer + OpenVidu.API_SESSIONS + "/" + this.sessionId);
request.setHeader(HttpHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded");
HttpResponse response;
try {
response = httpClient.execute(request);
response = OpenVidu.httpClient.execute(request);
} catch (IOException e) {
throw new OpenViduJavaClientException(e.getMessage(), e.getCause());
}
@ -185,8 +176,8 @@ public class Session {
* connections to the Session
* ({@link io.openvidu.java.client.Session#getActiveConnections()}) and use
* those values to call
* {@link io.openvidu.java.client.Session#forceDisconnect(String)} or
* {@link io.openvidu.java.client.Session#forceUnpublish(String)}
* {@link io.openvidu.java.client.Session#forceDisconnect(Connection)} or
* {@link io.openvidu.java.client.Session#forceUnpublish(Publisher)}
*
* @return true if the Session status has changed with respect to the server,
* false if not. This applies to any property or sub-property of the
@ -197,12 +188,12 @@ public class Session {
*/
public boolean fetch() throws OpenViduJavaClientException, OpenViduHttpException {
String beforeJSON = this.toJson();
HttpGet request = new HttpGet(this.urlOpenViduServer + OpenVidu.API_SESSIONS + "/" + this.sessionId);
HttpGet request = new HttpGet(OpenVidu.urlOpenViduServer + OpenVidu.API_SESSIONS + "/" + this.sessionId);
request.setHeader(HttpHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded");
HttpResponse response;
try {
response = httpClient.execute(request);
response = OpenVidu.httpClient.execute(request);
} catch (IOException e) {
throw new OpenViduJavaClientException(e.getMessage(), e.getCause());
}
@ -257,13 +248,13 @@ public class Session {
* @throws OpenViduHttpException
*/
public void forceDisconnect(String connectionId) throws OpenViduJavaClientException, OpenViduHttpException {
HttpDelete request = new HttpDelete(
this.urlOpenViduServer + OpenVidu.API_SESSIONS + "/" + this.sessionId + "/connection/" + connectionId);
HttpDelete request = new HttpDelete(OpenVidu.urlOpenViduServer + OpenVidu.API_SESSIONS + "/" + this.sessionId
+ "/connection/" + connectionId);
request.setHeader(HttpHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded");
HttpResponse response = null;
try {
response = httpClient.execute(request);
response = OpenVidu.httpClient.execute(request);
} catch (IOException e) {
throw new OpenViduJavaClientException(e.getMessage(), e.getCause());
}
@ -277,7 +268,11 @@ public class Session {
// other connections
if (connectionClosed != null) {
for (Publisher publisher : connectionClosed.getPublishers()) {
this.removeSubscribersForPublisher(publisher);
String streamId = publisher.getStreamId();
for (Connection connection : this.activeConnections.values()) {
connection.setSubscribers(connection.getSubscribers().stream()
.filter(subscriber -> !streamId.equals(subscriber)).collect(Collectors.toList()));
}
}
} else {
log.warn(
@ -332,12 +327,12 @@ public class Session {
*/
public void forceUnpublish(String streamId) throws OpenViduJavaClientException, OpenViduHttpException {
HttpDelete request = new HttpDelete(
this.urlOpenViduServer + OpenVidu.API_SESSIONS + "/" + this.sessionId + "/stream/" + streamId);
OpenVidu.urlOpenViduServer + OpenVidu.API_SESSIONS + "/" + this.sessionId + "/stream/" + streamId);
request.setHeader(HttpHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded");
HttpResponse response;
try {
response = httpClient.execute(request);
response = OpenVidu.httpClient.execute(request);
} catch (IOException e) {
throw new OpenViduJavaClientException(e.getMessage(), e.getCause());
}
@ -383,14 +378,7 @@ public class Session {
}
/**
* Returns whether the session is being recorded or not. <strong>This value will
* be the same as the one that returned method
* {@link io.openvidu.java.client.Session#fetch()} the last time it was
* called.</strong>
*
* To get the current actual value, you must call first
* {@link io.openvidu.java.client.Session#fetch()} and then
* {@link io.openvidu.java.client.Session#isBeingRecorded()}
* Returns whether the session is being recorded or not
*/
public boolean isBeingRecorded() {
return this.recording;
@ -418,7 +406,7 @@ public class Session {
return;
}
HttpPost request = new HttpPost(this.urlOpenViduServer + OpenVidu.API_SESSIONS);
HttpPost request = new HttpPost(OpenVidu.urlOpenViduServer + OpenVidu.API_SESSIONS);
JSONObject json = new JSONObject();
json.put("mediaMode", properties.mediaMode().name());
@ -438,7 +426,7 @@ public class Session {
HttpResponse response;
try {
response = httpClient.execute(request);
response = OpenVidu.httpClient.execute(request);
} catch (IOException e2) {
throw new OpenViduJavaClientException(e2.getMessage(), e2.getCause());
}
@ -470,12 +458,8 @@ public class Session {
return json;
}
private void removeSubscribersForPublisher(Publisher publisher) {
String streamId = publisher.getStreamId();
for (Connection connection : this.activeConnections.values()) {
connection.setSubscribers(connection.getSubscribers().stream()
.filter(subscriber -> !streamId.equals(subscriber)).collect(Collectors.toList()));
}
protected void setIsBeingRecorded(boolean recording) {
this.recording = recording;
}
@SuppressWarnings("unchecked")

View File

@ -383,7 +383,9 @@ public class KurentoSession implements Session {
JSONObject connections = new JSONObject();
JSONArray participants = new JSONArray();
this.participants.values().forEach(p -> {
participants.add(toJsonFunction.apply(p));
if (!ProtocolElements.RECORDER_PARTICIPANT_PUBLICID.equals(p.getParticipantPublicId())) {
participants.add(toJsonFunction.apply(p));
}
});
connections.put("numberOfElements", participants.size());
connections.put("content", participants);