Fixed #9
parent
6a94c5de94
commit
254762eb8a
|
@ -78,47 +78,51 @@ exports.handleDisconnect = function(client)
|
||||||
//save the padname of this session
|
//save the padname of this session
|
||||||
var sessionPad=session2pad[client.sessionId];
|
var sessionPad=session2pad[client.sessionId];
|
||||||
|
|
||||||
var author = sessioninfos[client.sessionId].author;
|
//if this connection was already etablished with a handshake, send a disconnect message to the others
|
||||||
|
if(sessioninfos[client.sessionId].author)
|
||||||
//get the author color out of the db
|
|
||||||
authorManager.getAuthorColorId(author, function(err, color)
|
|
||||||
{
|
{
|
||||||
if(err) throw err;
|
var author = sessioninfos[client.sessionId].author;
|
||||||
|
|
||||||
//prepare the notification for the other users on the pad, that this user left
|
//get the author color out of the db
|
||||||
var messageToTheOtherUsers = {
|
authorManager.getAuthorColorId(author, function(err, color)
|
||||||
"type": "COLLABROOM",
|
{
|
||||||
"data": {
|
if(err) throw err;
|
||||||
type: "USER_LEAVE",
|
|
||||||
userInfo: {
|
//prepare the notification for the other users on the pad, that this user left
|
||||||
"ip": "127.0.0.1",
|
var messageToTheOtherUsers = {
|
||||||
"colorId": color,
|
"type": "COLLABROOM",
|
||||||
"userAgent": "Anonymous",
|
"data": {
|
||||||
"userId": author
|
type: "USER_LEAVE",
|
||||||
|
userInfo: {
|
||||||
|
"ip": "127.0.0.1",
|
||||||
|
"colorId": color,
|
||||||
|
"userAgent": "Anonymous",
|
||||||
|
"userId": author
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
//Go trough all sessions of this pad, search and destroy the entry of this client
|
//Go trough all user that are still on the pad, and send them the USER_LEAVE message
|
||||||
for(i in pad2sessions[sessionPad])
|
for(i in pad2sessions[sessionPad])
|
||||||
{
|
|
||||||
if(pad2sessions[sessionPad][i] == client.sessionId)
|
|
||||||
{
|
{
|
||||||
delete pad2sessions[sessionPad][i];
|
socketio.clients[pad2sessions[sessionPad][i]].send(messageToTheOtherUsers);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//Go trough all user that are still on the pad, and send them the USER_LEAVE message
|
//Go trough all sessions of this pad, search and destroy the entry of this client
|
||||||
for(i in pad2sessions[sessionPad])
|
for(i in pad2sessions[sessionPad])
|
||||||
|
{
|
||||||
|
if(pad2sessions[sessionPad][i] == client.sessionId)
|
||||||
{
|
{
|
||||||
socketio.clients[pad2sessions[sessionPad][i]].send(messageToTheOtherUsers);
|
delete pad2sessions[sessionPad][i];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Delete the session2pad and sessioninfos entrys of this session
|
//Delete the session2pad and sessioninfos entrys of this session
|
||||||
delete session2pad[client.sessionId];
|
delete session2pad[client.sessionId];
|
||||||
delete sessioninfos[client.sessionId];
|
delete sessioninfos[client.sessionId];
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue