Skip to content

Commit

Permalink
Added more comment on socket communication.
Browse files Browse the repository at this point in the history
  • Loading branch information
pradeepmvn committed Oct 9, 2018
1 parent bb3a709 commit 5844986
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ app.set("socketCache",socketCache);
// Socket.io Communication
io.sockets.on('connection', function (socket) {
var jwt0='';
console.log("All Cookies: " + socket.request.headers.cookie);
console.log("All Cookies for Socket Connection: " + socket.request.headers.cookie);
try{
var cookieArr =socket.request.headers.cookie.split(";");
for (var i=0;i<cookieArr.length;i++){
Expand All @@ -86,15 +86,13 @@ io.sockets.on('connection', function (socket) {
break;
}
}
console.log("Adding Socket to Sockets List");
console.log("Socket Connection Request for jwt0: " +jwt0);
app.get("socketCache").set(jwt0, socket);
}catch (err) {
console.log('Problem when parsing the cookies. Ignoring socket' + err);
}

socket.on('disconnect', function(){
console.log("Disconnecting All Cookies: " + socket.request.headers.cookie);
console.log('Socket disconnected');
console.log("All Cookies for Socket disconnect: " + socket.request.headers.cookie);
var discjwt0='';
try{
var cookieArr =socket.request.headers.cookie.split(";");
Expand All @@ -104,8 +102,8 @@ io.sockets.on('connection', function (socket) {
break;
}
}
console.log("Removing SOCKET: "+discjwt0+" from List: "+ JSON.stringify(app.get("socketCache").keys()));
app.get("socketCache").del(jwt0);
console.log("Socket Disconnect Request. Removing: "+discjwt0+" from List: "+ JSON.stringify(app.get("socketCache").keys()));
app.get("socketCache").del(discjwt0);
}catch (err) {
console.log('Problem when parsing the cookies. Unable to delete socket' + err);
}
Expand Down

0 comments on commit 5844986

Please sign in to comment.