From 90ec6f2fb9937229e16b1e6e7131cfdf0db7cfc8 Mon Sep 17 00:00:00 2001 From: Khush Jammu Date: Sat, 30 May 2020 17:05:05 +0800 Subject: [PATCH] IT WORKS WITH THREE CLIENTS ON LOCALHOST --- public/js/chat.js | 11 ++--------- server.js | 11 ++++++----- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/public/js/chat.js b/public/js/chat.js index 488622a..69ce8a4 100644 --- a/public/js/chat.js +++ b/public/js/chat.js @@ -183,8 +183,8 @@ var VideoChat = { case "connected": logIt("connected"); // Once connected we no longer have a need for the signaling server, so disconnect - VideoChat.socket.off("token"); - VideoChat.socket.off("offer"); + // VideoChat.socket.off("token"); + // VideoChat.socket.off("offer"); break; case "disconnected": logIt("disconnected"); @@ -308,13 +308,6 @@ var VideoChat = { // Send ice candidate over websocket VideoChat.socket.emit("candidate", JSON.stringify(candidate), roomHash, uuid); }); - // Reset the buffer of local ICE candidates. This is not really needed, but it's good practice - // VideoChat.localICECandidates[uuid] = []; - // } else { - // console.log("attemped to run onAnswer on UUID ", uuid, " which already happened"); - // } - - }, // Called when a stream is added to the peer connection diff --git a/server.js b/server.js index 7b8865e..622fbd9 100644 --- a/server.js +++ b/server.js @@ -9,10 +9,11 @@ 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("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"); var public = path.join(__dirname, "public"); @@ -144,7 +145,7 @@ io.on("connection", function (socket) { }); // Listen for Heroku port, otherwise just use 3000 -var port = process.env.PORT || 443; +var port = process.env.PORT || 3000; http.listen(port, function () { console.log("http://localhost:" + port); });