mirror of https://github.com/OpenVidu/openvidu.git
openvidu-node-client: Update axios version. Fix unhandled exception while fetching sessions when session is created
parent
be7634c821
commit
b4b808e3f1
|
@ -9,7 +9,7 @@
|
|||
"version": "2.27.0",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"axios": "0.27.2",
|
||||
"axios": "1.4.0",
|
||||
"buffer": "6.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -347,12 +347,13 @@
|
|||
}
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "0.27.2",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz",
|
||||
"integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==",
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz",
|
||||
"integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.14.9",
|
||||
"form-data": "^4.0.0"
|
||||
"follow-redirects": "^1.15.0",
|
||||
"form-data": "^4.0.0",
|
||||
"proxy-from-env": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/balanced-match": {
|
||||
|
@ -3294,6 +3295,11 @@
|
|||
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/proxy-from-env": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
|
||||
},
|
||||
"node_modules/qs": {
|
||||
"version": "6.11.0",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
|
||||
|
@ -4747,12 +4753,13 @@
|
|||
"dev": true
|
||||
},
|
||||
"axios": {
|
||||
"version": "0.27.2",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz",
|
||||
"integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==",
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz",
|
||||
"integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==",
|
||||
"requires": {
|
||||
"follow-redirects": "^1.14.9",
|
||||
"form-data": "^4.0.0"
|
||||
"follow-redirects": "^1.15.0",
|
||||
"form-data": "^4.0.0",
|
||||
"proxy-from-env": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"balanced-match": {
|
||||
|
@ -7026,6 +7033,11 @@
|
|||
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",
|
||||
"dev": true
|
||||
},
|
||||
"proxy-from-env": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
|
||||
},
|
||||
"qs": {
|
||||
"version": "6.11.0",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"author": "OpenVidu",
|
||||
"dependencies": {
|
||||
"axios": "0.27.2",
|
||||
"axios": "1.4.0",
|
||||
"buffer": "6.0.3"
|
||||
},
|
||||
"description": "OpenVidu Node Client",
|
||||
|
|
|
@ -165,7 +165,6 @@ export class OpenVidu {
|
|||
public startRecording(sessionId: string, param2?: string | RecordingProperties): Promise<Recording> {
|
||||
return new Promise<Recording>((resolve, reject) => {
|
||||
let data;
|
||||
let rejected = false;
|
||||
|
||||
if (param2 != null) {
|
||||
if (typeof param2 === 'string') {
|
||||
|
@ -203,7 +202,8 @@ export class OpenVidu {
|
|||
headers: {
|
||||
Authorization: this.basicAuth,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
},
|
||||
validateStatus: (_) => true
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.status === 200) {
|
||||
|
@ -222,12 +222,12 @@ export class OpenVidu {
|
|||
resolve(r);
|
||||
} else {
|
||||
// ERROR response from openvidu-server. Resolve HTTP status
|
||||
rejected = true;
|
||||
this.handleError(res, reject);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
!rejected && this.handleError(error, reject);
|
||||
// Request error.
|
||||
this.handleError(error, reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -244,13 +244,13 @@ export class OpenVidu {
|
|||
*/
|
||||
public stopRecording(recordingId: string): Promise<Recording> {
|
||||
return new Promise<Recording>((resolve, reject) => {
|
||||
let rejected = false;
|
||||
axios
|
||||
.post(this.host + OpenVidu.API_RECORDINGS_STOP + '/' + recordingId, undefined, {
|
||||
headers: {
|
||||
Authorization: this.basicAuth,
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
},
|
||||
validateStatus: (_) => true
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.status === 200) {
|
||||
|
@ -269,12 +269,12 @@ export class OpenVidu {
|
|||
resolve(r);
|
||||
} else {
|
||||
// ERROR response from openvidu-server. Resolve HTTP status
|
||||
rejected = true;
|
||||
this.handleError(res, reject);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
!rejected && this.handleError(error, reject);
|
||||
// Request error.
|
||||
this.handleError(error, reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -291,13 +291,13 @@ export class OpenVidu {
|
|||
*/
|
||||
public getRecording(recordingId: string): Promise<Recording> {
|
||||
return new Promise<Recording>((resolve, reject) => {
|
||||
let rejected = false;
|
||||
axios
|
||||
.get(this.host + OpenVidu.API_RECORDINGS + '/' + recordingId, {
|
||||
headers: {
|
||||
Authorization: this.basicAuth,
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
},
|
||||
validateStatus: (_) => true
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.status === 200) {
|
||||
|
@ -305,12 +305,12 @@ export class OpenVidu {
|
|||
resolve(new Recording(res.data));
|
||||
} else {
|
||||
// ERROR response from openvidu-server. Resolve HTTP status
|
||||
rejected = true
|
||||
this.handleError(res, reject);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
!rejected && this.handleError(error, reject);
|
||||
// Request error.
|
||||
this.handleError(error, reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -322,12 +322,12 @@ export class OpenVidu {
|
|||
*/
|
||||
public listRecordings(): Promise<Recording[]> {
|
||||
return new Promise<Recording[]>((resolve, reject) => {
|
||||
let rejected = false;
|
||||
axios
|
||||
.get(this.host + OpenVidu.API_RECORDINGS, {
|
||||
headers: {
|
||||
Authorization: this.basicAuth
|
||||
}
|
||||
},
|
||||
validateStatus: (_) => true
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.status === 200) {
|
||||
|
@ -342,12 +342,12 @@ export class OpenVidu {
|
|||
resolve(recordingArray);
|
||||
} else {
|
||||
// ERROR response from openvidu-server. Resolve HTTP status
|
||||
rejected = true;
|
||||
this.handleError(res, reject);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
!rejected && this.handleError(error, reject);
|
||||
// Request error.
|
||||
this.handleError(error, reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -364,13 +364,13 @@ export class OpenVidu {
|
|||
*/
|
||||
public deleteRecording(recordingId: string): Promise<Error> {
|
||||
return new Promise<Error>((resolve, reject) => {
|
||||
let rejected = false;
|
||||
axios
|
||||
.delete(this.host + OpenVidu.API_RECORDINGS + '/' + recordingId, {
|
||||
headers: {
|
||||
Authorization: this.basicAuth,
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
},
|
||||
validateStatus: (_) => true
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.status === 204) {
|
||||
|
@ -378,12 +378,12 @@ export class OpenVidu {
|
|||
resolve(undefined);
|
||||
} else {
|
||||
// ERROR response from openvidu-server. Resolve HTTP status
|
||||
rejected = true;
|
||||
this.handleError(res, reject);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
!rejected && this.handleError(error, reject);
|
||||
// Request error.
|
||||
this.handleError(error, reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -413,7 +413,6 @@ export class OpenVidu {
|
|||
public startBroadcast(sessionId: string, broadcastUrl: string, properties?: RecordingProperties): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
let data;
|
||||
let rejected = false;
|
||||
if (properties != undefined) {
|
||||
data = {
|
||||
session: sessionId,
|
||||
|
@ -439,7 +438,8 @@ export class OpenVidu {
|
|||
headers: {
|
||||
Authorization: this.basicAuth,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
},
|
||||
validateStatus: (_) => true
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.status === 200) {
|
||||
|
@ -456,12 +456,12 @@ export class OpenVidu {
|
|||
resolve();
|
||||
} else {
|
||||
// ERROR response from openvidu-server. Resolve HTTP status
|
||||
rejected = true;
|
||||
this.handleError(res, reject);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
!rejected && this.handleError(error, reject);
|
||||
// Request error.
|
||||
this.handleError(error, reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -478,7 +478,6 @@ export class OpenVidu {
|
|||
*/
|
||||
public stopBroadcast(sessionId: string): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
let rejected = false;
|
||||
axios
|
||||
.post(
|
||||
this.host + OpenVidu.API_BROADCAST_STOP,
|
||||
|
@ -487,7 +486,8 @@ export class OpenVidu {
|
|||
headers: {
|
||||
Authorization: this.basicAuth,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
},
|
||||
validateStatus: (_) => true
|
||||
}
|
||||
)
|
||||
.then((res) => {
|
||||
|
@ -506,12 +506,12 @@ export class OpenVidu {
|
|||
resolve();
|
||||
} else {
|
||||
// ERROR response from openvidu-server. Resolve HTTP status
|
||||
rejected = true;
|
||||
this.handleError(res, reject);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
!rejected && this.handleError(error, reject);
|
||||
// Request error.
|
||||
this.handleError(error, reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -525,12 +525,12 @@ export class OpenVidu {
|
|||
*/
|
||||
public fetch(): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
let rejected = false;
|
||||
axios
|
||||
.get(this.host + OpenVidu.API_SESSIONS + '?pendingConnections=true', {
|
||||
headers: {
|
||||
Authorization: this.basicAuth
|
||||
}
|
||||
},
|
||||
validateStatus: (_) => true
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.status === 200) {
|
||||
|
@ -572,12 +572,12 @@ export class OpenVidu {
|
|||
resolve(hasChanged);
|
||||
} else {
|
||||
// ERROR response from openvidu-server. Resolve HTTP status
|
||||
rejected = true;
|
||||
this.handleError(res, reject);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
!rejected && this.handleError(error, reject);
|
||||
// Request error.
|
||||
this.handleError(error, reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -657,12 +657,12 @@ export class OpenVidu {
|
|||
};
|
||||
|
||||
return new Promise<{ changes: boolean; sessionChanges: ObjMap<boolean> }>((resolve, reject) => {
|
||||
let rejected = false;
|
||||
axios
|
||||
.get(this.host + OpenVidu.API_SESSIONS + '?webRtcStats=true', {
|
||||
headers: {
|
||||
Authorization: this.basicAuth
|
||||
}
|
||||
},
|
||||
validateStatus: (_) => true
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.status === 200) {
|
||||
|
@ -727,12 +727,12 @@ export class OpenVidu {
|
|||
resolve({ changes: globalChanges, sessionChanges });
|
||||
} else {
|
||||
// ERROR response from openvidu-server. Resolve HTTP status
|
||||
rejected = true;
|
||||
this.handleError(res, reject);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
!rejected && this.handleError(error, reject);
|
||||
// Request error.
|
||||
this.handleError(error, reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -110,7 +110,6 @@ export class Session {
|
|||
*/
|
||||
public generateToken(tokenOptions?: TokenOptions): Promise<string> {
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
let rejected = false;
|
||||
const data = JSON.stringify({
|
||||
session: this.sessionId,
|
||||
role: !!tokenOptions && !!tokenOptions.role ? tokenOptions.role : null,
|
||||
|
@ -122,7 +121,8 @@ export class Session {
|
|||
headers: {
|
||||
Authorization: this.ov.basicAuth,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
},
|
||||
validateStatus: (_) => true
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.status === 200) {
|
||||
|
@ -130,12 +130,12 @@ export class Session {
|
|||
resolve(res.data.token);
|
||||
} else {
|
||||
// ERROR response from openvidu-server. Resolve HTTP status
|
||||
rejected = true;
|
||||
this.ov.handleError(res, reject);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
!rejected && this.ov.handleError(error, reject);
|
||||
// Request error.
|
||||
this.ov.handleError(error, reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -150,7 +150,6 @@ export class Session {
|
|||
*/
|
||||
public createConnection(connectionProperties?: ConnectionProperties): Promise<Connection> {
|
||||
return new Promise<Connection>((resolve, reject) => {
|
||||
let rejected = false;
|
||||
const data = JSON.stringify({
|
||||
type: !!connectionProperties && !!connectionProperties.type ? connectionProperties.type : null,
|
||||
data: !!connectionProperties && !!connectionProperties.data ? connectionProperties.data : null,
|
||||
|
@ -171,7 +170,8 @@ export class Session {
|
|||
headers: {
|
||||
Authorization: this.ov.basicAuth,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
},
|
||||
validateStatus: (_) => true
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.status === 200) {
|
||||
|
@ -184,11 +184,11 @@ export class Session {
|
|||
resolve(new Connection(res.data));
|
||||
} else {
|
||||
// ERROR response from openvidu-server. Resolve HTTP status
|
||||
rejected = true;
|
||||
this.ov.handleError(res, reject)
|
||||
this.ov.handleError(res, reject);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
// Request error.
|
||||
this.ov.handleError(error, reject);
|
||||
});
|
||||
});
|
||||
|
@ -202,13 +202,13 @@ export class Session {
|
|||
*/
|
||||
public close(): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
let rejected = false;
|
||||
axios
|
||||
.delete(this.ov.host + OpenVidu.API_SESSIONS + '/' + this.sessionId, {
|
||||
headers: {
|
||||
Authorization: this.ov.basicAuth,
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
},
|
||||
validateStatus: (_) => true
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.status === 204) {
|
||||
|
@ -218,12 +218,12 @@ export class Session {
|
|||
resolve();
|
||||
} else {
|
||||
// ERROR response from openvidu-server. Resolve HTTP status
|
||||
rejected = true;
|
||||
this.ov.handleError(res, reject);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
!rejected && this.ov.handleError(error, reject);
|
||||
// Request error.
|
||||
this.ov.handleError(error, reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -240,14 +240,14 @@ export class Session {
|
|||
*/
|
||||
public fetch(): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
let rejected = false;
|
||||
const beforeJSON: string = JSON.stringify(this, this.removeCircularOpenViduReference);
|
||||
axios
|
||||
.get(this.ov.host + OpenVidu.API_SESSIONS + '/' + this.sessionId + '?pendingConnections=true', {
|
||||
headers: {
|
||||
Authorization: this.ov.basicAuth,
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
},
|
||||
validateStatus: (_) => true
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.status === 200) {
|
||||
|
@ -259,12 +259,12 @@ export class Session {
|
|||
resolve(hasChanged);
|
||||
} else {
|
||||
// ERROR response from openvidu-server. Resolve HTTP status
|
||||
rejected = true;
|
||||
this.ov.handleError(res, reject);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
!rejected && this.ov.handleError(error, reject);
|
||||
// Request error.
|
||||
this.ov.handleError(error, reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -288,14 +288,14 @@ export class Session {
|
|||
*/
|
||||
public forceDisconnect(connection: string | Connection): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
let rejected = false;
|
||||
const connectionId: string = typeof connection === 'string' ? connection : (<Connection>connection).connectionId;
|
||||
axios
|
||||
.delete(this.ov.host + OpenVidu.API_SESSIONS + '/' + this.sessionId + '/connection/' + connectionId, {
|
||||
headers: {
|
||||
Authorization: this.ov.basicAuth,
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
},
|
||||
validateStatus: (_) => true
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.status === 204) {
|
||||
|
@ -337,12 +337,12 @@ export class Session {
|
|||
resolve();
|
||||
} else {
|
||||
// ERROR response from openvidu-server. Resolve HTTP status
|
||||
rejected = true;
|
||||
this.ov.handleError(res, reject);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
!rejected && this.ov.handleError(error, reject);
|
||||
// Request error.
|
||||
this.ov.handleError(error, reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -364,14 +364,14 @@ export class Session {
|
|||
*/
|
||||
public forceUnpublish(publisher: string | Publisher): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
let rejected = false;
|
||||
const streamId: string = typeof publisher === 'string' ? publisher : (<Publisher>publisher).streamId;
|
||||
axios
|
||||
.delete(this.ov.host + OpenVidu.API_SESSIONS + '/' + this.sessionId + '/stream/' + streamId, {
|
||||
headers: {
|
||||
Authorization: this.ov.basicAuth,
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
},
|
||||
validateStatus: (_) => true
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.status === 204) {
|
||||
|
@ -397,12 +397,12 @@ export class Session {
|
|||
resolve();
|
||||
} else {
|
||||
// ERROR response from openvidu-server. Resolve HTTP status
|
||||
rejected = true;
|
||||
this.ov.handleError(res, reject);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
!rejected && this.ov.handleError(error, reject);
|
||||
// Request error.
|
||||
this.ov.handleError(error, reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -434,20 +434,19 @@ export class Session {
|
|||
*/
|
||||
public updateConnection(connectionId: string, connectionProperties: ConnectionProperties): Promise<Connection | undefined> {
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
let rejected = false;
|
||||
axios
|
||||
.patch(this.ov.host + OpenVidu.API_SESSIONS + '/' + this.sessionId + '/connection/' + connectionId, connectionProperties, {
|
||||
headers: {
|
||||
Authorization: this.ov.basicAuth,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
},
|
||||
validateStatus: (_) => true
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.status === 200) {
|
||||
logger.log('Connection ' + connectionId + ' updated');
|
||||
} else {
|
||||
// ERROR response from openvidu-server. Resolve HTTP status
|
||||
rejected = true;
|
||||
this.ov.handleError(res, reject);
|
||||
return;
|
||||
}
|
||||
|
@ -467,7 +466,8 @@ export class Session {
|
|||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
!rejected && this.ov.handleError(error, reject);
|
||||
// Request error.
|
||||
this.ov.handleError(error, reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -484,7 +484,6 @@ export class Session {
|
|||
*/
|
||||
public getSessionHttp(): Promise<string> {
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
let rejected = false;
|
||||
if (!!this.sessionId) {
|
||||
resolve(this.sessionId);
|
||||
}
|
||||
|
@ -498,7 +497,8 @@ export class Session {
|
|||
headers: {
|
||||
Authorization: this.ov.basicAuth,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
},
|
||||
validateStatus: (_) => true
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.status === 200) {
|
||||
|
@ -514,20 +514,20 @@ export class Session {
|
|||
this.properties.allowTranscoding = res.data.allowTranscoding;
|
||||
this.sanitizeDefaultSessionProperties(this.properties);
|
||||
resolve(this.sessionId);
|
||||
} else if (res.status === 409) {
|
||||
// 'customSessionId' already existed
|
||||
this.sessionId = this.properties.customSessionId;
|
||||
this.fetch()
|
||||
.then(() => resolve(this.sessionId))
|
||||
.catch((error) => this.ov.handleError(error, reject));
|
||||
} else {
|
||||
// ERROR response from openvidu-server. Resolve HTTP status
|
||||
rejected = true;
|
||||
this.ov.handleError(res, reject);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
if (!!error.response && error.response.status === 409) {
|
||||
// 'customSessionId' already existed
|
||||
this.sessionId = this.properties.customSessionId;
|
||||
this.fetch().then(() => resolve(this.sessionId));
|
||||
} else {
|
||||
!rejected && this.ov.handleError(error, reject);
|
||||
}
|
||||
// Request error.
|
||||
this.ov.handleError(error, reject);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue