mirror of https://github.com/OpenVidu/openvidu.git
OpenVidu Server URL now is expected as part of the sessionId
parent
d6fde59ad3
commit
58ec882eff
File diff suppressed because one or more lines are too long
|
@ -29,21 +29,15 @@ export class OpenVidu {
|
|||
|
||||
openVidu: OpenViduInternal;
|
||||
|
||||
constructor();
|
||||
constructor(wsUri: string);
|
||||
constructor(wsUri?: string) {
|
||||
if (wsUri) {
|
||||
this.openVidu = new OpenViduInternal(wsUri);
|
||||
} else {
|
||||
constructor() {
|
||||
this.openVidu = new OpenViduInternal();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
initSession(apiKey: string, sessionId: string): Session;
|
||||
initSession(sessionId: string): Session;
|
||||
|
||||
initSession(param1, param2?): any {
|
||||
if (this.checkSystemRequirements()){
|
||||
if (this.checkSystemRequirements()) {
|
||||
if (typeof param2 == "string") {
|
||||
return new Session(this.openVidu.initSession(param2), this);
|
||||
} else {
|
||||
|
@ -60,7 +54,7 @@ export class OpenVidu {
|
|||
|
||||
initPublisher(parentId: string, cameraOptions?: any, callback?: Function): any {
|
||||
if (this.checkSystemRequirements()) {
|
||||
if (cameraOptions != null){
|
||||
if (cameraOptions != null) {
|
||||
let cameraOptionsAux = {
|
||||
audio: cameraOptions.audio != null ? cameraOptions.audio : true,
|
||||
video: cameraOptions.video != null ? cameraOptions.video : true,
|
||||
|
|
|
@ -30,31 +30,7 @@ export class OpenViduInternal {
|
|||
private camera: Stream;
|
||||
private remoteStreams: Stream[] = [];
|
||||
|
||||
constructor();
|
||||
constructor(wsUri: string);
|
||||
constructor(wsUri?: string) {
|
||||
if (wsUri) {
|
||||
this.wsUri = wsUri;
|
||||
if (this.wsUri.charAt(wsUri.length - 1) != '/') {
|
||||
this.wsUri += '/';
|
||||
}
|
||||
this.checkNgrokUri();
|
||||
this.wsUri += 'room';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
checkNgrokUri() {
|
||||
if (this.wsUri.indexOf(".ngrok.io") !== -1) {
|
||||
// OpenVidu server URL referes to a ngrok IP: secure wss protocol and delete port of URL
|
||||
this.wsUri = this.wsUri.replace("ws://", "wss://");
|
||||
let regex = /\.ngrok\.io:\d+/;
|
||||
this.wsUri = this.wsUri.replace(regex, ".ngrok.io");
|
||||
} else if (this.wsUri.indexOf("localhost") !== -1) {
|
||||
// OpenVidu server URL referes to localhost IP
|
||||
|
||||
}
|
||||
}
|
||||
constructor() { };
|
||||
|
||||
|
||||
/* NEW METHODS */
|
||||
|
|
|
@ -29,10 +29,24 @@ export class SessionInternal {
|
|||
constructor(private openVidu: OpenViduInternal, private sessionId: string) {
|
||||
this.localParticipant = new Connection(this.openVidu, true, this);
|
||||
if (!this.openVidu.getWsUri()) {
|
||||
this.openVidu.setWsUri(this.sessionId.substring(0, this.sessionId.lastIndexOf('/')) + '/room');
|
||||
this.openVidu.setWsUri(this.checkNgrokUri(sessionId));
|
||||
}
|
||||
}
|
||||
|
||||
checkNgrokUri(sessionId: string): string {
|
||||
sessionId = sessionId.substring(0, sessionId.lastIndexOf('/')) + '/room';
|
||||
if (sessionId.indexOf(".ngrok.io") !== -1) {
|
||||
// OpenVidu server URL referes to a ngrok IP: secure wss protocol and delete port of URL
|
||||
sessionId = sessionId.replace("ws://", "wss://");
|
||||
let regex = /\.ngrok\.io:\d+/;
|
||||
sessionId = sessionId.replace(regex, ".ngrok.io");
|
||||
} else if ((sessionId.indexOf("localhost") !== -1) || (sessionId.indexOf("127.0.0.1") != -1)) {
|
||||
// OpenVidu server URL referes to localhost IP
|
||||
|
||||
}
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* NEW METHODS */
|
||||
|
|
|
@ -19,3 +19,6 @@ cp openvidu-browser/src/main/resources/static/js/OpenVidu.js ../openvidu-tutoria
|
|||
|
||||
# openvidu-mvc-node
|
||||
cp openvidu-browser/src/main/resources/static/js/OpenVidu.js ../openvidu-tutorials/openvidu-mvc-node/public/OpenVidu.js
|
||||
|
||||
# openvidu-getaroom
|
||||
cp openvidu-browser/src/main/resources/static/js/OpenVidu.js ../openvidu-tutorials/openvidu-getaroom/web/OpenVidu.js
|
||||
|
|
Loading…
Reference in New Issue