Changing behavior of the same user on a pad. Kick old sessions instead of refusing new

This commit is contained in:
Peter 'Pita' Martischka 2011-06-04 18:02:22 +01:00
parent bf32c18d8d
commit b692ffec0b
2 changed files with 18 additions and 30 deletions

View File

@ -520,15 +520,14 @@ function handleClientReady(client, message)
},
function(callback)
{
//Check if this author is already on the pad, if yes, kick him!
//Check if this author is already on the pad, if yes, kick the other sessions!
if(pad2sessions[message.padId])
{
for(var i in pad2sessions[message.padId])
{
if(sessioninfos[pad2sessions[message.padId][i]].author == author)
{
client.send({disconnect:"doublelogin"});
return;
socketio.clients[pad2sessions[message.padId][i]].send({disconnect:"doublelogin"});
}
}
}

View File

@ -90,39 +90,28 @@ function handshake()
//if we haven't recieved the clientVars yet, then this message should it be
if(!receivedClientVars)
{
//We get a disconnect message
if(window.console)
console.log(obj);
receivedClientVars=true;
clientVars = obj;
clientVars.userAgent=navigator.userAgent;
clientVars.collab_client_vars.clientAgent=navigator.userAgent;
pad.init();
initalized=true;
}
//This handles every Message after the clientVars
else
{
if(obj.disconnect)
{
socket.disconnect();
padconnectionstatus.disconnected("userdup");
return;
}
//yeah, the clientVars are here :). So we can start initalizing the Pad
else
{
if(window.console)
console.log(obj);
receivedClientVars=true;
clientVars = obj;
clientVars.userAgent=navigator.userAgent;
clientVars.collab_client_vars.clientAgent=navigator.userAgent;
pad.init();
initalized=true;
}
}
//This handles every Message after the clientVars
else
{
//We can't handle the message before we initalized the pad, so let this message bounce back in 100ms
if(!initalized)
{
setTimeOut(this(obj), 100);
}
//We're initalized, so give this message to the collabClient
else
{
pad.collabClient.handleMessageFromServer(obj);