mirror of https://github.com/OpenVidu/openvidu.git
SDKs: fetch remote session on createSession 409
parent
defba84160
commit
918ef299ae
|
@ -142,14 +142,12 @@ public class OpenVidu {
|
||||||
* @return The created session
|
* @return The created session
|
||||||
*
|
*
|
||||||
* @throws OpenViduJavaClientException
|
* @throws OpenViduJavaClientException
|
||||||
* @throws OpenViduHttpException Value returned from
|
* @throws OpenViduHttpException The status code carries a specific
|
||||||
|
* meaning
|
||||||
* {@link io.openvidu.java.client.OpenViduHttpException#getStatus()}
|
* {@link io.openvidu.java.client.OpenViduHttpException#getStatus()}
|
||||||
* <ul>
|
* (see <a href=
|
||||||
* <li><code>409</code>: you are trying to
|
* "/en/stable/reference-docs/REST-API/#post-session">REST
|
||||||
* assign an already-in-use custom sessionId
|
* API</a>)
|
||||||
* to the session. See
|
|
||||||
* {@link io.openvidu.java.client.SessionProperties#customSessionId()}</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
*/
|
||||||
public Session createSession(SessionProperties properties)
|
public Session createSession(SessionProperties properties)
|
||||||
throws OpenViduJavaClientException, OpenViduHttpException {
|
throws OpenViduJavaClientException, OpenViduHttpException {
|
||||||
|
@ -167,28 +165,12 @@ public class OpenVidu {
|
||||||
* @return The new created session
|
* @return The new created session
|
||||||
*
|
*
|
||||||
* @throws OpenViduJavaClientException
|
* @throws OpenViduJavaClientException
|
||||||
* @throws OpenViduHttpException Value returned from
|
* @throws OpenViduHttpException The status code carries a specific
|
||||||
|
* meaning
|
||||||
* {@link io.openvidu.java.client.OpenViduHttpException#getStatus()}
|
* {@link io.openvidu.java.client.OpenViduHttpException#getStatus()}
|
||||||
* <ul>
|
* (see <a href=
|
||||||
* <li><code>404</code>: no session exists
|
* "/en/stable/reference-docs/REST-API/#post-recording-start">REST
|
||||||
* for the passed <i>sessionId</i></li>
|
* API</a>)
|
||||||
* <li><code>406</code>: the session has no
|
|
||||||
* connected participants</li>
|
|
||||||
* <li><code>422</code>: "resolution"
|
|
||||||
* parameter exceeds acceptable values (for
|
|
||||||
* both width and height, min 100px and max
|
|
||||||
* 1999px) or trying to start a recording
|
|
||||||
* with both "hasAudio" and "hasVideo" to
|
|
||||||
* false</li>
|
|
||||||
* <li><code>409</code>: the session is not
|
|
||||||
* configured for using
|
|
||||||
* {@link io.openvidu.java.client.MediaMode#ROUTED}
|
|
||||||
* or it is already being recorded</li>
|
|
||||||
* <li><code>501</code>: OpenVidu Server
|
|
||||||
* recording module is disabled
|
|
||||||
* (<i>OPENVIDU_RECORDING</i> property set
|
|
||||||
* to <i>false</i>)</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
*/
|
||||||
public Recording startRecording(String sessionId, RecordingProperties properties)
|
public Recording startRecording(String sessionId, RecordingProperties properties)
|
||||||
throws OpenViduJavaClientException, OpenViduHttpException {
|
throws OpenViduJavaClientException, OpenViduHttpException {
|
||||||
|
@ -246,28 +228,12 @@ public class OpenVidu {
|
||||||
* guarantees
|
* guarantees
|
||||||
*
|
*
|
||||||
* @throws OpenViduJavaClientException
|
* @throws OpenViduJavaClientException
|
||||||
* @throws OpenViduHttpException Value returned from
|
* @throws OpenViduHttpException The status code carries a specific
|
||||||
|
* meaning
|
||||||
* {@link io.openvidu.java.client.OpenViduHttpException#getStatus()}
|
* {@link io.openvidu.java.client.OpenViduHttpException#getStatus()}
|
||||||
* <ul>
|
* (see <a href=
|
||||||
* <li><code>404</code>: no session exists
|
* "/en/stable/reference-docs/REST-API/#post-recording-start">REST
|
||||||
* for the passed <i>sessionId</i></li>
|
* API</a>)
|
||||||
* <li><code>406</code>: the session has no
|
|
||||||
* connected participants</li>
|
|
||||||
* <li><code>422</code>: "resolution"
|
|
||||||
* parameter exceeds acceptable values (for
|
|
||||||
* both width and height, min 100px and max
|
|
||||||
* 1999px) or trying to start a recording
|
|
||||||
* with both "hasAudio" and "hasVideo" to
|
|
||||||
* false</li>
|
|
||||||
* <li><code>409</code>: the session is not
|
|
||||||
* configured for using
|
|
||||||
* {@link io.openvidu.java.client.MediaMode#ROUTED}
|
|
||||||
* or it is already being recorded</li>
|
|
||||||
* <li><code>501</code>: OpenVidu Server
|
|
||||||
* recording module is disabled
|
|
||||||
* (<i>OPENVIDU_RECORDING</i> property set
|
|
||||||
* to <i>false</i>)</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
*/
|
||||||
public Recording startRecording(String sessionId, String name)
|
public Recording startRecording(String sessionId, String name)
|
||||||
throws OpenViduJavaClientException, OpenViduHttpException {
|
throws OpenViduJavaClientException, OpenViduHttpException {
|
||||||
|
@ -287,28 +253,12 @@ public class OpenVidu {
|
||||||
* guarantees
|
* guarantees
|
||||||
*
|
*
|
||||||
* @throws OpenViduJavaClientException
|
* @throws OpenViduJavaClientException
|
||||||
* @throws OpenViduHttpException Value returned from
|
* @throws OpenViduHttpException The status code carries a specific
|
||||||
|
* meaning
|
||||||
* {@link io.openvidu.java.client.OpenViduHttpException#getStatus()}
|
* {@link io.openvidu.java.client.OpenViduHttpException#getStatus()}
|
||||||
* <ul>
|
* (see <a href=
|
||||||
* <li><code>404</code>: no session exists
|
* "/en/stable/reference-docs/REST-API/#post-recording-start">REST
|
||||||
* for the passed <i>sessionId</i></li>
|
* API</a>)
|
||||||
* <li><code>406</code>: the session has no
|
|
||||||
* connected participants</li>
|
|
||||||
* <li><code>422</code>: "resolution"
|
|
||||||
* parameter exceeds acceptable values (for
|
|
||||||
* both width and height, min 100px and max
|
|
||||||
* 1999px) or trying to start a recording
|
|
||||||
* with both "hasAudio" and "hasVideo" to
|
|
||||||
* false</li>
|
|
||||||
* <li><code>409</code>: the session is not
|
|
||||||
* configured for using
|
|
||||||
* {@link io.openvidu.java.client.MediaMode#ROUTED}
|
|
||||||
* or it is already being recorded</li>
|
|
||||||
* <li><code>501</code>: OpenVidu Server
|
|
||||||
* recording module is disabled
|
|
||||||
* (<i>OPENVIDU_RECORDING</i> property set
|
|
||||||
* to <i>false</i>)</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
*/
|
||||||
public Recording startRecording(String sessionId) throws OpenViduJavaClientException, OpenViduHttpException {
|
public Recording startRecording(String sessionId) throws OpenViduJavaClientException, OpenViduHttpException {
|
||||||
return this.startRecording(sessionId, "");
|
return this.startRecording(sessionId, "");
|
||||||
|
@ -322,16 +272,12 @@ public class OpenVidu {
|
||||||
* @return The stopped recording
|
* @return The stopped recording
|
||||||
*
|
*
|
||||||
* @throws OpenViduJavaClientException
|
* @throws OpenViduJavaClientException
|
||||||
* @throws OpenViduHttpException Value returned from
|
* @throws OpenViduHttpException The status code carries a specific
|
||||||
|
* meaning
|
||||||
* {@link io.openvidu.java.client.OpenViduHttpException#getStatus()}
|
* {@link io.openvidu.java.client.OpenViduHttpException#getStatus()}
|
||||||
* <ul>
|
* (see <a href=
|
||||||
* <li><code>404</code>: no recording exists
|
* "/en/stable/reference-docs/REST-API/#post-recording-stop">REST
|
||||||
* for the passed <i>recordingId</i></li>
|
* API</a>)
|
||||||
* <li><code>406</code>: recording has
|
|
||||||
* <i>starting</i> status. Wait until
|
|
||||||
* <i>started</i> status before stopping the
|
|
||||||
* recording</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
*/
|
||||||
public Recording stopRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException {
|
public Recording stopRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException {
|
||||||
HttpPost request = new HttpPost(this.hostname + API_RECORDINGS_STOP + "/" + recordingId);
|
HttpPost request = new HttpPost(this.hostname + API_RECORDINGS_STOP + "/" + recordingId);
|
||||||
|
@ -369,12 +315,12 @@ public class OpenVidu {
|
||||||
* @param recordingId The id property of the recording you want to retrieve
|
* @param recordingId The id property of the recording you want to retrieve
|
||||||
*
|
*
|
||||||
* @throws OpenViduJavaClientException
|
* @throws OpenViduJavaClientException
|
||||||
* @throws OpenViduHttpException Value returned from
|
* @throws OpenViduHttpException The status code carries a specific
|
||||||
|
* meaning
|
||||||
* {@link io.openvidu.java.client.OpenViduHttpException#getStatus()}
|
* {@link io.openvidu.java.client.OpenViduHttpException#getStatus()}
|
||||||
* <ul>
|
* (see <a href=
|
||||||
* <li><code>404</code>: no recording exists
|
* "/en/stable/reference-docs/REST-API/#get-recording">REST
|
||||||
* for the passed <i>recordingId</i></li>
|
* API</a>)
|
||||||
* </ul>
|
|
||||||
*/
|
*/
|
||||||
public Recording getRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException {
|
public Recording getRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException {
|
||||||
HttpGet request = new HttpGet(this.hostname + API_RECORDINGS + "/" + recordingId);
|
HttpGet request = new HttpGet(this.hostname + API_RECORDINGS + "/" + recordingId);
|
||||||
|
@ -443,15 +389,12 @@ public class OpenVidu {
|
||||||
* @param recordingId The id property of the recording you want to delete
|
* @param recordingId The id property of the recording you want to delete
|
||||||
*
|
*
|
||||||
* @throws OpenViduJavaClientException
|
* @throws OpenViduJavaClientException
|
||||||
* @throws OpenViduHttpException Value returned from
|
* @throws OpenViduHttpException The status code carries a specific
|
||||||
|
* meaning
|
||||||
* {@link io.openvidu.java.client.OpenViduHttpException#getStatus()}
|
* {@link io.openvidu.java.client.OpenViduHttpException#getStatus()}
|
||||||
* <ul>
|
* (see <a href=
|
||||||
* <li><code>404</code>: no recording exists
|
* "/en/stable/reference-docs/REST-API/#delete-recording">REST
|
||||||
* for the passed <i>recordingId</i></li>
|
* API</a>)
|
||||||
* <li><code>409</code>: the recording has
|
|
||||||
* <i>started</i> status. Stop it before
|
|
||||||
* deletion</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
*/
|
||||||
public void deleteRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException {
|
public void deleteRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException {
|
||||||
HttpDelete request = new HttpDelete(this.hostname + API_RECORDINGS + "/" + recordingId);
|
HttpDelete request = new HttpDelete(this.hostname + API_RECORDINGS + "/" + recordingId);
|
||||||
|
@ -491,7 +434,11 @@ public class OpenVidu {
|
||||||
* automatically updates the inner affected connections for that specific
|
* automatically updates the inner affected connections for that specific
|
||||||
* Session</li>
|
* Session</li>
|
||||||
* <li>Calling {@link io.openvidu.java.client.Session#forceUnpublish(Publisher)}
|
* <li>Calling {@link io.openvidu.java.client.Session#forceUnpublish(Publisher)}
|
||||||
* also automatically updates the inner affected connections for that specific
|
* automatically updates the inner affected connections for that specific
|
||||||
|
* Session</li>
|
||||||
|
* <li>Calling
|
||||||
|
* {@link io.openvidu.java.client.Session#updateConnection(String, ConnectionProperties)}
|
||||||
|
* automatically updates the inner affected connection for that specific
|
||||||
* Session</li>
|
* Session</li>
|
||||||
* <li>Calling {@link io.openvidu.java.client.OpenVidu#startRecording(String)}
|
* <li>Calling {@link io.openvidu.java.client.OpenVidu#startRecording(String)}
|
||||||
* and {@link io.openvidu.java.client.OpenVidu#stopRecording(String)}
|
* and {@link io.openvidu.java.client.OpenVidu#stopRecording(String)}
|
||||||
|
|
|
@ -19,7 +19,7 @@ package io.openvidu.java.client;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines error responses from OpenVidu Server. See error codes at
|
* Defines error responses from OpenVidu Server. See error codes at
|
||||||
* https://docs.openvidu.io/en/stable/reference-docs/REST-API/
|
* <a href="/en/stable/reference-docs/REST-API">REST API docs</a>
|
||||||
*/
|
*/
|
||||||
public class OpenViduHttpException extends OpenViduException {
|
public class OpenViduHttpException extends OpenViduException {
|
||||||
|
|
||||||
|
@ -32,7 +32,8 @@ public class OpenViduHttpException extends OpenViduException {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The unexpected status of the HTTP request
|
* @return The unexpected status of the HTTP request. See error codes meaning at
|
||||||
|
* <a href="/en/stable/reference-docs/REST-API">REST API docs</a>
|
||||||
*/
|
*/
|
||||||
public int getStatus() {
|
public int getStatus() {
|
||||||
return this.status;
|
return this.status;
|
||||||
|
|
|
@ -480,7 +480,7 @@ public class Session {
|
||||||
*
|
*
|
||||||
* The affected client will trigger one <a href=
|
* The affected client will trigger one <a href=
|
||||||
* "/en/stable/api/openvidu-browser/classes/ConnectionPropertyChangedEvent.html">
|
* "/en/stable/api/openvidu-browser/classes/ConnectionPropertyChangedEvent.html">
|
||||||
* ConnectionPropertyChangedEvent </a> for each modified property.
|
* ConnectionPropertyChangedEvent</a> for each modified property.
|
||||||
*
|
*
|
||||||
* @param connectionId The Connection to modify
|
* @param connectionId The Connection to modify
|
||||||
* @param connectionProperties A ConnectionProperties object with the new values
|
* @param connectionProperties A ConnectionProperties object with the new values
|
||||||
|
@ -678,6 +678,10 @@ public class Session {
|
||||||
|
|
||||||
this.properties = responseProperties;
|
this.properties = responseProperties;
|
||||||
log.info("Session '{}' created", this.sessionId);
|
log.info("Session '{}' created", this.sessionId);
|
||||||
|
} else if (statusCode == org.apache.http.HttpStatus.SC_CONFLICT) {
|
||||||
|
// 'customSessionId' already existed
|
||||||
|
this.sessionId = properties.customSessionId();
|
||||||
|
this.fetch();
|
||||||
} else {
|
} else {
|
||||||
throw new OpenViduHttpException(statusCode);
|
throw new OpenViduHttpException(statusCode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,12 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import axios from 'axios';
|
import axios, { AxiosError } from 'axios';
|
||||||
import { Connection } from './Connection';
|
import { Connection } from './Connection';
|
||||||
import { Recording } from './Recording';
|
import { Recording } from './Recording';
|
||||||
import { RecordingProperties } from './RecordingProperties';
|
import { RecordingProperties } from './RecordingProperties';
|
||||||
import { Session } from './Session';
|
import { Session } from './Session';
|
||||||
import { SessionProperties } from './SessionProperties';
|
import { SessionProperties } from './SessionProperties';
|
||||||
import { RecordingLayout } from './RecordingLayout';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hidden
|
* @hidden
|
||||||
|
@ -79,8 +78,8 @@ export class OpenVidu {
|
||||||
* - Calling [[Session.close]] automatically removes the Session from the list of active Sessions
|
* - Calling [[Session.close]] automatically removes the Session from the list of active Sessions
|
||||||
* - Calling [[Session.forceDisconnect]] automatically updates the inner affected connections for that specific Session
|
* - Calling [[Session.forceDisconnect]] automatically updates the inner affected connections for that specific Session
|
||||||
* - Calling [[Session.forceUnpublish]] also automatically updates the inner affected connections for that specific Session
|
* - Calling [[Session.forceUnpublish]] also automatically updates the inner affected connections for that specific Session
|
||||||
* - Calling [[OpenVidu.startRecording]] and [[OpenVidu.stopRecording]] automatically updates the recording status of the
|
* - Calling [[Session.updateConnection]] automatically updates the inner affected connection for that specific Session
|
||||||
* Session ([[Session.recording]])
|
* - Calling [[OpenVidu.startRecording]] and [[OpenVidu.stopRecording]] automatically updates the recording status of the Session ([[Session.recording]])
|
||||||
*
|
*
|
||||||
* To get the array of active sessions with their current actual value, you must call [[OpenVidu.fetch]] before consulting
|
* To get the array of active sessions with their current actual value, you must call [[OpenVidu.fetch]] before consulting
|
||||||
* property [[activeSessions]]
|
* property [[activeSessions]]
|
||||||
|
@ -129,13 +128,8 @@ export class OpenVidu {
|
||||||
* @param properties Custom RecordingProperties to apply to this Recording. This will override the global default values set to the Session with [[SessionProperties.defaultRecordingProperties]]
|
* @param properties Custom RecordingProperties to apply to this Recording. This will override the global default values set to the Session with [[SessionProperties.defaultRecordingProperties]]
|
||||||
*
|
*
|
||||||
* @returns A Promise that is resolved to the [[Recording]] if it successfully started (the recording can be stopped with guarantees) and rejected with an Error
|
* @returns A Promise that is resolved to the [[Recording]] if it successfully started (the recording can be stopped with guarantees) and rejected with an Error
|
||||||
* object if not. This Error object has as `message` property with the following values:
|
* object if not. This Error object has as `message` property with a status code with a specific meaning
|
||||||
* - `404`: no session exists for the passed `sessionId`
|
* (see [REST API](/en/stable/reference-docs/REST-API/#post-recording-start)).
|
||||||
* - `406`: the session has no connected participants
|
|
||||||
* - `422`: when passing [[RecordingProperties]], `resolution` parameter exceeds acceptable values (for both width and height, min 100px and max 1999px) or trying
|
|
||||||
* to start a recording with both `hasAudio` and `hasVideo` to false
|
|
||||||
* - `409`: the session is not configured for using [[MediaMode.ROUTED]] or it is already being recorded
|
|
||||||
* - `501`: OpenVidu Server recording module is disabled (`OPENVIDU_RECORDING` property set to `false`)
|
|
||||||
*/
|
*/
|
||||||
public startRecording(sessionId: string, param2?: string | RecordingProperties): Promise<Recording> {
|
public startRecording(sessionId: string, param2?: string | RecordingProperties): Promise<Recording> {
|
||||||
return new Promise<Recording>((resolve, reject) => {
|
return new Promise<Recording>((resolve, reject) => {
|
||||||
|
@ -199,18 +193,7 @@ export class OpenVidu {
|
||||||
reject(new Error(res.status.toString()));
|
reject(new Error(res.status.toString()));
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
if (error.response) {
|
this.handleError(error, reject);
|
||||||
// The request was made and the server responded with a status code (not 2xx)
|
|
||||||
reject(new Error(error.response.status.toString()));
|
|
||||||
} else if (error.request) {
|
|
||||||
// The request was made but no response was received
|
|
||||||
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
|
|
||||||
// http.ClientRequest in node.js
|
|
||||||
reject(error.request);
|
|
||||||
} else {
|
|
||||||
// Something happened in setting up the request that triggered an Error
|
|
||||||
reject(error.message);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -220,9 +203,9 @@ export class OpenVidu {
|
||||||
*
|
*
|
||||||
* @param recordingId The `id` property of the [[Recording]] you want to stop
|
* @param recordingId The `id` property of the [[Recording]] you want to stop
|
||||||
*
|
*
|
||||||
* @returns A Promise that is resolved to the [[Recording]] if it successfully stopped and rejected with an Error object if not. This Error object has as `message` property with the following values:
|
* @returns A Promise that is resolved to the [[Recording]] if it successfully stopped and rejected with an Error object if not.
|
||||||
* - `404`: no recording exists for the passed `recordingId`
|
* This Error object has as `message` property with a status code with a specific meaning
|
||||||
* - `406`: recording has `starting` status. Wait until `started` status before stopping the recording
|
* (see [REST API](/en/stable/reference-docs/REST-API/#post-recording-stop)).
|
||||||
*/
|
*/
|
||||||
public stopRecording(recordingId: string): Promise<Recording> {
|
public stopRecording(recordingId: string): Promise<Recording> {
|
||||||
return new Promise<Recording>((resolve, reject) => {
|
return new Promise<Recording>((resolve, reject) => {
|
||||||
|
@ -253,17 +236,7 @@ export class OpenVidu {
|
||||||
reject(new Error(res.status.toString()));
|
reject(new Error(res.status.toString()));
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
if (error.response) {
|
this.handleError(error, reject);
|
||||||
// The request was made and the server responded with a status code (not 2xx)
|
|
||||||
reject(new Error(error.response.status.toString()));
|
|
||||||
} else if (error.request) {
|
|
||||||
// The request was made but no response was received `error.request` is an instance of XMLHttpRequest
|
|
||||||
// in the browser and an instance of http.ClientRequest in node.js
|
|
||||||
reject(new Error(error.request));
|
|
||||||
} else {
|
|
||||||
// Something happened in setting up the request that triggered an Error
|
|
||||||
reject(new Error(error.message));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -273,8 +246,9 @@ export class OpenVidu {
|
||||||
*
|
*
|
||||||
* @param recordingId The `id` property of the [[Recording]] you want to retrieve
|
* @param recordingId The `id` property of the [[Recording]] you want to retrieve
|
||||||
*
|
*
|
||||||
* @returns A Promise that is resolved to the [[Recording]] if it successfully stopped and rejected with an Error object if not. This Error object has as `message` property with the following values:
|
* @returns A Promise that is resolved to the [[Recording]] if it successfully stopped and rejected with an Error object if not.
|
||||||
* - `404`: no recording exists for the passed `recordingId`
|
* This Error object has as `message` property with a status code with a specific meaning
|
||||||
|
* (see [REST API](/en/stable/reference-docs/REST-API/#get-recording)).
|
||||||
*/
|
*/
|
||||||
public getRecording(recordingId: string): Promise<Recording> {
|
public getRecording(recordingId: string): Promise<Recording> {
|
||||||
return new Promise<Recording>((resolve, reject) => {
|
return new Promise<Recording>((resolve, reject) => {
|
||||||
|
@ -297,18 +271,7 @@ export class OpenVidu {
|
||||||
reject(new Error(res.status.toString()));
|
reject(new Error(res.status.toString()));
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
if (error.response) {
|
this.handleError(error, reject);
|
||||||
// The request was made and the server responded with a status code (not 2xx)
|
|
||||||
reject(new Error(error.response.status.toString()));
|
|
||||||
} else if (error.request) {
|
|
||||||
// The request was made but no response was received
|
|
||||||
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
|
|
||||||
// http.ClientRequest in node.js
|
|
||||||
reject(new Error(error.request));
|
|
||||||
} else {
|
|
||||||
// Something happened in setting up the request that triggered an Error
|
|
||||||
reject(new Error(error.message));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -345,18 +308,7 @@ export class OpenVidu {
|
||||||
reject(new Error(res.status.toString()));
|
reject(new Error(res.status.toString()));
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
if (error.response) {
|
this.handleError(error, reject);
|
||||||
// The request was made and the server responded with a status code (not 2xx)
|
|
||||||
reject(new Error(error.response.status.toString()));
|
|
||||||
} else if (error.request) {
|
|
||||||
// The request was made but no response was received
|
|
||||||
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
|
|
||||||
// http.ClientRequest in node.js
|
|
||||||
reject(new Error(error.request));
|
|
||||||
} else {
|
|
||||||
// Something happened in setting up the request that triggered an Error
|
|
||||||
reject(new Error(error.message));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -366,9 +318,9 @@ export class OpenVidu {
|
||||||
*
|
*
|
||||||
* @param recordingId
|
* @param recordingId
|
||||||
*
|
*
|
||||||
* @returns A Promise that is resolved if the Recording was successfully deleted and rejected with an Error object if not. This Error object has as `message` property with the following values:
|
* @returns A Promise that is resolved if the Recording was successfully deleted and rejected with an Error object if not.
|
||||||
* - `404`: no recording exists for the passed `recordingId`
|
* This Error object has as `message` property with a status code with a specific meaning
|
||||||
* - `409`: the recording has `started` status. Stop it before deletion
|
* (see [REST API](/en/stable/reference-docs/REST-API/#delete-recording)).
|
||||||
*/
|
*/
|
||||||
public deleteRecording(recordingId: string): Promise<Error> {
|
public deleteRecording(recordingId: string): Promise<Error> {
|
||||||
return new Promise<Error>((resolve, reject) => {
|
return new Promise<Error>((resolve, reject) => {
|
||||||
|
@ -391,18 +343,7 @@ export class OpenVidu {
|
||||||
reject(new Error(res.status.toString()));
|
reject(new Error(res.status.toString()));
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
if (error.response) {
|
this.handleError(error, reject);
|
||||||
// The request was made and the server responded with a status code (not 2xx)
|
|
||||||
reject(new Error(error.response.status.toString()));
|
|
||||||
} else if (error.request) {
|
|
||||||
// The request was made but no response was received
|
|
||||||
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
|
|
||||||
// http.ClientRequest in node.js
|
|
||||||
reject(new Error(error.request));
|
|
||||||
} else {
|
|
||||||
// Something happened in setting up the request that triggered an Error
|
|
||||||
reject(new Error(error.message));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -472,18 +413,7 @@ export class OpenVidu {
|
||||||
reject(new Error(res.status.toString()));
|
reject(new Error(res.status.toString()));
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
if (error.response) {
|
this.handleError(error, reject);
|
||||||
// The request was made and the server responded with a status code (not 2xx)
|
|
||||||
reject(new Error(error.response.status.toString()));
|
|
||||||
} else if (error.request) {
|
|
||||||
// The request was made but no response was received
|
|
||||||
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
|
|
||||||
// http.ClientRequest in node.js
|
|
||||||
reject(error);
|
|
||||||
} else {
|
|
||||||
// Something happened in setting up the request that triggered an Error
|
|
||||||
reject(new Error(error.message));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -640,18 +570,7 @@ export class OpenVidu {
|
||||||
reject(new Error(res.status.toString()));
|
reject(new Error(res.status.toString()));
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
if (error.response) {
|
this.handleError(error, reject);
|
||||||
// The request was made and the server responded with a status code (not 2xx)
|
|
||||||
reject(new Error(error.response.status.toString()));
|
|
||||||
} else if (error.request) {
|
|
||||||
// The request was made but no response was received
|
|
||||||
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
|
|
||||||
// http.ClientRequest in node.js
|
|
||||||
reject(new Error(error.request));
|
|
||||||
} else {
|
|
||||||
// Something happened in setting up the request that triggered an Error
|
|
||||||
reject(new Error(error.message));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -671,4 +590,22 @@ export class OpenVidu {
|
||||||
this.host = url.protocol + '//' + url.host;
|
this.host = url.protocol + '//' + url.host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
|
handleError(error: AxiosError, reject: (reason?: any) => void) {
|
||||||
|
if (error.response) {
|
||||||
|
// The request was made and the server responded with a status code (not 2xx)
|
||||||
|
reject(new Error(error.response.status.toString()));
|
||||||
|
} else if (error.request) {
|
||||||
|
// The request was made but no response was received
|
||||||
|
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
|
||||||
|
// http.ClientRequest in node.js
|
||||||
|
reject(new Error(error.request));
|
||||||
|
} else {
|
||||||
|
// Something happened in setting up the request that triggered an Error
|
||||||
|
reject(new Error(error.message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import axios, { AxiosError } from 'axios';
|
import axios, { AxiosError } from 'axios';
|
||||||
import { VideoCodec } from './VideoCodec';
|
|
||||||
import { Connection } from './Connection';
|
import { Connection } from './Connection';
|
||||||
import { ConnectionProperties } from './ConnectionProperties';
|
import { ConnectionProperties } from './ConnectionProperties';
|
||||||
import { MediaMode } from './MediaMode';
|
import { MediaMode } from './MediaMode';
|
||||||
|
@ -128,7 +127,7 @@ export class Session {
|
||||||
reject(new Error(res.status.toString()));
|
reject(new Error(res.status.toString()));
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
this.handleError(error, reject);
|
this.ov.handleError(error, reject);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -178,7 +177,7 @@ export class Session {
|
||||||
reject(new Error(res.status.toString()));
|
reject(new Error(res.status.toString()));
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
this.handleError(error, reject);
|
this.ov.handleError(error, reject);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -210,7 +209,7 @@ export class Session {
|
||||||
reject(new Error(res.status.toString()));
|
reject(new Error(res.status.toString()));
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
this.handleError(error, reject);
|
this.ov.handleError(error, reject);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -250,7 +249,7 @@ export class Session {
|
||||||
reject(new Error(res.status.toString()));
|
reject(new Error(res.status.toString()));
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
this.handleError(error, reject);
|
this.ov.handleError(error, reject);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -324,7 +323,7 @@ export class Session {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
this.handleError(error, reject);
|
this.ov.handleError(error, reject);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -382,7 +381,7 @@ export class Session {
|
||||||
reject(new Error(res.status.toString()));
|
reject(new Error(res.status.toString()));
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
this.handleError(error, reject);
|
this.ov.handleError(error, reject);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -443,7 +442,7 @@ export class Session {
|
||||||
resolve(existingConnection);
|
resolve(existingConnection);
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
this.handleError(error, reject);
|
this.ov.handleError(error, reject);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -501,23 +500,12 @@ export class Session {
|
||||||
reject(new Error(res.status.toString()));
|
reject(new Error(res.status.toString()));
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
if (error.response) {
|
if (!!error.response && error.response.status === 409) {
|
||||||
// The request was made and the server responded with a status code (not 2xx)
|
// 'customSessionId' already existed
|
||||||
if (error.response.status === 409) {
|
this.sessionId = this.properties.customSessionId;
|
||||||
// 'customSessionId' already existed
|
this.fetch().then(() => resolve(this.sessionId));
|
||||||
this.sessionId = this.properties.customSessionId;
|
|
||||||
resolve(this.sessionId);
|
|
||||||
} else {
|
|
||||||
reject(new Error(error.response.status.toString()));
|
|
||||||
}
|
|
||||||
} else if (error.request) {
|
|
||||||
// The request was made but no response was received
|
|
||||||
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
|
|
||||||
// http.ClientRequest in node.js
|
|
||||||
reject(new Error(error.request));
|
|
||||||
} else {
|
} else {
|
||||||
// Something happened in setting up the request that triggered an Error
|
this.ov.handleError(error, reject);
|
||||||
reject(new Error(error.message));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -589,10 +577,10 @@ export class Session {
|
||||||
this.connections.forEach(connection => {
|
this.connections.forEach(connection => {
|
||||||
if (connection.connectionProperties.customIceServers != null &&
|
if (connection.connectionProperties.customIceServers != null &&
|
||||||
connection.connectionProperties.customIceServers.length > 0) {
|
connection.connectionProperties.customIceServers.length > 0) {
|
||||||
// Order alphabetically Ice servers using url just to keep the same list order.
|
// Order alphabetically Ice servers using url just to keep the same list order.
|
||||||
const simpleIceComparator = (a: IceServerProperties, b: IceServerProperties) => (a.url > b.url) ? 1 : -1
|
const simpleIceComparator = (a: IceServerProperties, b: IceServerProperties) => (a.url > b.url) ? 1 : -1
|
||||||
connection.connectionProperties.customIceServers.sort(simpleIceComparator);
|
connection.connectionProperties.customIceServers.sort(simpleIceComparator);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Populate activeConnections array
|
// Populate activeConnections array
|
||||||
this.updateActiveConnectionsArray();
|
this.updateActiveConnectionsArray();
|
||||||
|
@ -645,24 +633,6 @@ export class Session {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @hidden
|
|
||||||
*/
|
|
||||||
private handleError(error: AxiosError, reject: (reason?: any) => void) {
|
|
||||||
if (error.response) {
|
|
||||||
// The request was made and the server responded with a status code (not 2xx)
|
|
||||||
reject(new Error(error.response.status.toString()));
|
|
||||||
} else if (error.request) {
|
|
||||||
// The request was made but no response was received
|
|
||||||
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
|
|
||||||
// http.ClientRequest in node.js
|
|
||||||
reject(new Error(error.request));
|
|
||||||
} else {
|
|
||||||
// Something happened in setting up the request that triggered an Error
|
|
||||||
reject(new Error(error.message));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hidden
|
* @hidden
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue