mute-server
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -79,8 +79,23 @@ /* | ||
socket.on('disconnect', function () { | ||
network.connected[socket.room][socket.replicaNumber]--; | ||
console.log('Il reste que : ', network.connected); | ||
if(network.connected[socket.room][socket.replicaNumber] === 0) { | ||
var i = 0; | ||
var key; | ||
// Remove the socket for this replica number | ||
if(network.connected[socket.room] !== null && network.connected[socket.room] !== undefined | ||
&& network.connected[socket.room][socket.replicaNumber] !== null | ||
&& network.connected[socket.room][socket.replicaNumber] !== undefined | ||
&& network.connected[socket.room][socket.replicaNumber][socket.id] !== null | ||
&& network.connected[socket.room][socket.replicaNumber][socket.id] !== undefined) { | ||
delete network.connected[socket.room][socket.replicaNumber][socket.id]; | ||
} | ||
for(key in network.connected[socket.room][socket.replicaNumber]) { | ||
i++; | ||
} | ||
// If the replica number references no socketID | ||
// Delete it | ||
if(i === 0) { | ||
network.emit('disconnect', { replicaNumber: socket.replicaNumber, docID: socket.room }); | ||
network.io.sockets.in(socket.room).emit('userLeft', { replicaNumber: socket.replicaNumber }); | ||
delete network.connected[socket.room][socket.replicaNumber]; | ||
console.log('Il reste que : ', network.connected); | ||
} | ||
@@ -101,9 +116,8 @@ }); | ||
if(network.connected[args.socket.room][args.replicaNumber] !== null | ||
&& network.connected[args.socket.room][args.replicaNumber] !== undefined) { | ||
network.connected[args.socket.room][args.replicaNumber]++; | ||
if(network.connected[socket.room] === null || network.connected[socket.room] === undefined | ||
|| network.connected[socket.room][socket.replicaNumber] === null | ||
|| network.connected[socket.room][socket.replicaNumber] === undefined) { | ||
network.connected[socket.room][socket.replicaNumber] = {}; | ||
} | ||
else { | ||
network.connected[args.socket.room][args.replicaNumber] = 1; | ||
} | ||
network.connected[socket.room][socket.replicaNumber][socket.id] = true; | ||
@@ -110,0 +124,0 @@ infosUsersModule.addUser(args.socket.room, args.replicaNumber, args.username); |
{ | ||
"name": "mute-server", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Server-side application creating a data-structure representing a text and initializing a network to allow clients to edit the text and broadcast theirs changes in real-time", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58525
482