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