Let the Server Handle USERINFO_UPATE correctly

pull/1/head
Peter 'Pita' Martischka 2011-03-27 13:13:46 +01:00
parent 9360814242
commit 328e7f1aa4
1 changed files with 20 additions and 4 deletions

View File

@ -149,10 +149,6 @@ exports.handleMessage = function(client, message)
function handleUserInfoUpdate(client, message)
{
//check if all ok
if(message.data.userInfo.name == null)
{
throw "USERINFO_UPDATE Message have no name!";
}
if(message.data.userInfo.colorId == null)
{
throw "USERINFO_UPDATE Message have no colorId!";
@ -164,6 +160,26 @@ function handleUserInfoUpdate(client, message)
//Tell the authorManager about the new attributes
authorManager.setAuthorColorId(author, message.data.userInfo.colorId);
authorManager.setAuthorName(author, message.data.userInfo.name);
var padId = session2pad[client.sessionId];
//set a null name, when there is no name set. cause the client wants it null
if(message.data.userInfo.name == null)
{
message.data.userInfo.name = null;
}
//The Client don't know about a USERINFO_UPDATE, it can handle only new user_newinfo, so change the message type
message.data.type = "USER_NEWINFO";
//Send the other clients on the pad the update message
for(i in pad2sessions[padId])
{
if(pad2sessions[padId][i] != client.sessionId)
{
socketio.clients[pad2sessions[padId][i]].send(message);
}
}
}
/**