From d96750d4f8fdb8b071f1be8bdf7a705480ae8d74 Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Wed, 31 May 2017 17:49:13 +0200 Subject: [PATCH] HTTPS and shared certificate with openvidu-server --- .../video-session/video-session.component.ts | 25 +++++++++++++------ .../frontend/src/environments/environment.ts | 2 +- .../application-container.properties | 5 ++++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/openvidu-sample-app/src/angular/frontend/src/app/components/video-session/video-session.component.ts b/openvidu-sample-app/src/angular/frontend/src/app/components/video-session/video-session.component.ts index fbce3282..e0e69aeb 100644 --- a/openvidu-sample-app/src/angular/frontend/src/app/components/video-session/video-session.component.ts +++ b/openvidu-sample-app/src/angular/frontend/src/app/components/video-session/video-session.component.ts @@ -50,6 +50,8 @@ export class VideoSessionComponent implements OnInit { // 2) Specify the actions when events take place this.session.on('streamCreated', (event) => { + console.warn("STREAM CREATED!"); + console.warn(event.stream); this.session.subscribe(event.stream, 'subscriber', { insertMode: 'append', width: '100%', @@ -63,32 +65,43 @@ export class VideoSessionComponent implements OnInit { }); this.session.on('connectionCreated', (event) => { - if (event.connection.connectionId == this.session.connection.connectionId){ + if (event.connection.connectionId == this.session.connection.connectionId) { console.warn("YOUR OWN CONNECTION CREATED!"); } else { console.warn("OTHER USER'S CONNECTION CREATED!"); } - console.warn(event); + console.warn(event.connection); }); this.session.on('connectionDestroyed', (event) => { console.warn("OTHER USER'S CONNECTION DESTROYED!"); - console.warn(event); + console.warn(event.connection); }); // 3) Connect to the session - this.session.connect(this.token, "CLIENT:" + this.authenticationService.getCurrentUser().name ,(error) => { + this.session.connect(this.token, "CLIENT:" + this.authenticationService.getCurrentUser().name, (error) => { // If the connection is successful, initialize a publisher and publish to the session if (!error) { - if (this.authenticationService.isTeacher()){ + if (this.authenticationService.isTeacher()) { // 4) Get your own camera stream with the desired resolution and publish it, only if the user is supposed to do so this.publisher = this.OV.initPublisher('publisher', this.cameraOptions); + this.publisher.on('accessAllowed', () => { + console.warn("CAMERA ACCESS ALLOWED!"); + }); + this.publisher.on('accessDenied', () => { + console.warn("CAMERA ACCESS DENIED!"); + }); + this.publisher.on('streamCreated', (event) => { + console.warn("STREAM CREATED BY PUBLISHER!"); + console.warn(event.stream); + }) + // 5) Publish your stream this.session.publish(this.publisher); @@ -112,11 +125,9 @@ export class VideoSessionComponent implements OnInit { // If the user is the teacher: creates the session and gets a token (with PUBLISHER role) this.videoSessionService.createSession(this.lesson.id).subscribe( sessionId => { // {0: sessionId} - console.warn(sessionId); this.sessionId = sessionId[0]; this.videoSessionService.generateToken(this.lesson.id).subscribe( sessionIdAndToken => { - console.warn(sessionIdAndToken); this.token = sessionIdAndToken[1]; console.warn("Token: " + this.token); console.warn("SessionId: " + this.sessionId); diff --git a/openvidu-sample-app/src/angular/frontend/src/environments/environment.ts b/openvidu-sample-app/src/angular/frontend/src/environments/environment.ts index c8db4711..b75519de 100644 --- a/openvidu-sample-app/src/angular/frontend/src/environments/environment.ts +++ b/openvidu-sample-app/src/angular/frontend/src/environments/environment.ts @@ -5,5 +5,5 @@ export const environment = { production: false, - URL_BACK: 'http://localhost:5000' + URL_BACK: 'https://localhost:5000' }; diff --git a/openvidu-sample-app/src/main/resources/application-container.properties b/openvidu-sample-app/src/main/resources/application-container.properties index 68c3bd7e..5100294b 100644 --- a/openvidu-sample-app/src/main/resources/application-container.properties +++ b/openvidu-sample-app/src/main/resources/application-container.properties @@ -1,6 +1,11 @@ spring.profiles.active=container server.port: 5000 +server.ssl.enabled: true +server.ssl.key-store: classpath:openvidu-selfsigned.jks +server.ssl.key-store-password: openvidu +server.ssl.key-store-type: JKS +server.ssl.key-alias: openvidu-selfsigned spring.datasource.url: jdbc:mysql://mysql:3306/openvidu_sample_app spring.datasource.username: op-root