Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
user: "publisher2",
pass: "pass",
role: OpenViduRole.PUBLISHER
}, {
user: "subscriber",
pass: "pass",
role: OpenViduRole.SUBSCRIBER
}];
// Environment variable: URL where our OpenVidu server is listening
var OPENVIDU_URL = process.argv[2];
// Environment variable: secret shared with our OpenVidu server
var OPENVIDU_SECRET = process.argv[3];
// Entrypoint to OpenVidu Node Client SDK
var OV = new OpenVidu(OPENVIDU_URL, OPENVIDU_SECRET);
// Collection to pair session names with OpenVidu Session objects
var mapSessions = {};
// Collection to pair session names with tokens
var mapSessionNamesTokens = {};
console.log("App listening on port 5000");
/* CONFIGURATION */
/* REST API */
app.post('/', loginController);
app.get('/', loginController);
})); // Parse application/vnd.api+json as json
// Listen (start app with node server.js)
var options = {
key: fs.readFileSync('openvidukey.pem'),
cert: fs.readFileSync('openviducert.pem')
};
https.createServer(options, app).listen(5000);
// Environment variable: URL where our OpenVidu server is listening
var OPENVIDU_URL = process.argv[2];
// Environment variable: secret shared with our OpenVidu server
var OPENVIDU_SECRET = process.argv[3];
// Entrypoint to OpenVidu Node Client SDK
var OV = new OpenVidu(OPENVIDU_URL, OPENVIDU_SECRET);
// Collection to pair session names with OpenVidu Session objects
var mapSessions = {};
// Collection to pair session names with tokens
var mapSessionNamesTokens = {};
console.log("App listening on port 5000");
/* Session API */
// Get token (add new user to session)
app.post('/api/get-token', function (req, res) {
// The video-call to connect
private getToken(): Promise {
this.OV_NodeClient = new OpenViduAPI(this.openviduUrl, this.openviduSecret);
if (!this.sessionProperties.customSessionId) {
this.sessionProperties.customSessionId = this.fixedSessionId;
}
return this.OV_NodeClient.createSession(this.sessionProperties)
.then(session_NodeClient => {
return session_NodeClient.generateToken();
});
}
getToken(): Promise {
const OV_NodeClient = new OpenViduAPI(this.openviduUrl, this.openviduSecret);
if (!this.sessionProperties.customSessionId) {
this.sessionProperties.customSessionId = this.sessionName;
}
return OV_NodeClient.createSession(this.sessionProperties)
.then(session_NodeClient => {
return session_NodeClient.generateToken();
});
}
openSessionApiDialog() {
const dialogRef = this.dialog.open(SessionApiDialogComponent, {
data: {
openVidu: new OpenViduAPI(this.openviduUrl, this.openviduSecret),
sessionId: !!this.session ? this.session.sessionId : this.sessionName
},
width: '280px'
});
dialogRef.afterClosed().subscribe((result: string) => {
document.getElementById('session-api-btn').classList.remove('cdk-program-focused');
});
}
return new Promise((resolve, reject) => {
const OV = new OpenViduAPI(openviduURL, openviduSecret);
OV.createSession(sessionProperties)
.then(session => {
this.sessionIdSession.set(session.getSessionId(), session);
this.sessionIdTokenOpenViduRole.set(session.getSessionId(), new Map());
resolve(session.getSessionId());
})
.catch(error => {
reject(error);
});
});
}