Skip to content

Commit 4a289ab

Browse files
authored
Merge pull request #9 from startprogress/master
Discard variable "socket.Index"
2 parents 1c335ff + 9599eef commit 4a289ab

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

server.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ io.sockets.on('connection', function(socket) {
1717
if (users.indexOf(nickname) > -1) {
1818
socket.emit('nickExisted');
1919
} else {
20-
socket.userIndex = users.length;
20+
//socket.userIndex = users.length;
2121
socket.nickname = nickname;
2222
users.push(nickname);
2323
socket.emit('loginSuccess');
@@ -27,7 +27,8 @@ io.sockets.on('connection', function(socket) {
2727
//user leaves
2828
socket.on('disconnect', function() {
2929
if (socket.nickname != null) {
30-
users.splice(socket.userIndex, 1);
30+
//users.splice(socket.userIndex, 1);
31+
users.splice(users.indexOf(nickname), 1);
3132
socket.broadcast.emit('system', socket.nickname, users.length, 'logout');
3233
}
3334
});
@@ -39,4 +40,4 @@ io.sockets.on('connection', function(socket) {
3940
socket.on('img', function(imgData, color) {
4041
socket.broadcast.emit('newImg', socket.nickname, imgData, color);
4142
});
42-
});
43+
});

0 commit comments

Comments
 (0)