OpenVidu Server URL now is expected as part of the sessionId

pull/20/head
pabloFuente 2017-07-12 18:56:13 +02:00
parent d6fde59ad3
commit 58ec882eff
5 changed files with 470 additions and 868 deletions

File diff suppressed because one or more lines are too long

View File

@ -29,21 +29,15 @@ export class OpenVidu {
openVidu: OpenViduInternal;
constructor();
constructor(wsUri: string);
constructor(wsUri?: string) {
if (wsUri) {
this.openVidu = new OpenViduInternal(wsUri);
} else {
this.openVidu = new OpenViduInternal();
}
}
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,

View File

@ -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 */

View File

@ -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 */

View File

@ -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