HTTPS and shared certificate with openvidu-server

pull/20/head
pabloFuente 2017-05-31 17:49:13 +02:00
parent 88ff95e24f
commit d96750d4f8
3 changed files with 24 additions and 8 deletions

View File

@ -50,6 +50,8 @@ export class VideoSessionComponent implements OnInit {
// 2) Specify the actions when events take place // 2) Specify the actions when events take place
this.session.on('streamCreated', (event) => { this.session.on('streamCreated', (event) => {
console.warn("STREAM CREATED!");
console.warn(event.stream);
this.session.subscribe(event.stream, 'subscriber', { this.session.subscribe(event.stream, 'subscriber', {
insertMode: 'append', insertMode: 'append',
width: '100%', width: '100%',
@ -63,32 +65,43 @@ export class VideoSessionComponent implements OnInit {
}); });
this.session.on('connectionCreated', (event) => { 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!"); console.warn("YOUR OWN CONNECTION CREATED!");
} else { } else {
console.warn("OTHER USER'S CONNECTION CREATED!"); console.warn("OTHER USER'S CONNECTION CREATED!");
} }
console.warn(event); console.warn(event.connection);
}); });
this.session.on('connectionDestroyed', (event) => { this.session.on('connectionDestroyed', (event) => {
console.warn("OTHER USER'S CONNECTION DESTROYED!"); console.warn("OTHER USER'S CONNECTION DESTROYED!");
console.warn(event); console.warn(event.connection);
}); });
// 3) Connect to the session // 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 the connection is successful, initialize a publisher and publish to the session
if (!error) { 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 // 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 = 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 // 5) Publish your stream
this.session.publish(this.publisher); 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) // If the user is the teacher: creates the session and gets a token (with PUBLISHER role)
this.videoSessionService.createSession(this.lesson.id).subscribe( this.videoSessionService.createSession(this.lesson.id).subscribe(
sessionId => { // {0: sessionId} sessionId => { // {0: sessionId}
console.warn(sessionId);
this.sessionId = sessionId[0]; this.sessionId = sessionId[0];
this.videoSessionService.generateToken(this.lesson.id).subscribe( this.videoSessionService.generateToken(this.lesson.id).subscribe(
sessionIdAndToken => { sessionIdAndToken => {
console.warn(sessionIdAndToken);
this.token = sessionIdAndToken[1]; this.token = sessionIdAndToken[1];
console.warn("Token: " + this.token); console.warn("Token: " + this.token);
console.warn("SessionId: " + this.sessionId); console.warn("SessionId: " + this.sessionId);

View File

@ -5,5 +5,5 @@
export const environment = { export const environment = {
production: false, production: false,
URL_BACK: 'http://localhost:5000' URL_BACK: 'https://localhost:5000'
}; };

View File

@ -1,6 +1,11 @@
spring.profiles.active=container spring.profiles.active=container
server.port: 5000 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.url: jdbc:mysql://mysql:3306/openvidu_sample_app
spring.datasource.username: op-root spring.datasource.username: op-root