removed debug code from server side code

This commit is contained in:
Taichi Kato 2020-05-30 19:25:33 +08:00
parent 64ef2b4196
commit cd1cbe8112

View File

@ -9,10 +9,6 @@ var twilio = require("twilio")(twillioAccountSID, twillioAuthToken);
var express = require("express");
var app = express();
const fs = require("fs");
// var http = require("https").createServer({
// key: fs.readFileSync('/Users/khushjammu/certs/privkey.pem'),
// cert: fs.readFileSync('/Users/khushjammu/certs/cert.pem')
// }, app);
var http = require("http").createServer(app);
var io = require("socket.io")(http);
var path = require("path");
@ -83,22 +79,8 @@ io.on("connection", function (socket) {
var numClients = typeof clients !== "undefined" ? clients.length : 0;
if (numClients === 0) {
socket.join(room);
twilio.tokens.create(function (err, response) {
if (err) {
logIt(err, room);
} else {
logIt("Token generated. Returning it to the browser client", room);
socket.emit("token", response);
// Existing callers initiates call with user
}
});
} else if (numClients < 5) {
socket.join(room);
logIt("Connected clients", room);
for (var clientId in clients.sockets) {
logIt("ID: " + clientId, room);
}
// When the client is not the first to join the room, all clients are ready.
logIt("Broadcasting ready message", room);
socket.broadcast.to(room).emit("willInitiateCall", socket.id, room);