ground work for different users on server and players on client

This commit is contained in:
Jeena Paradies 2012-07-13 21:10:08 +02:00
parent e37d1eeb2e
commit 2cb401bbd3
9 changed files with 122 additions and 54 deletions

View file

@ -13,8 +13,10 @@ define(["Chuck/ServerGame"], function(ServerGame) {
Channel.prototype.addUser = function(user){
this.users[user.id] = user;
user.sendCommand('joinSuccess', this.name);
this.sendCommandToAllUsersBut('userJoined', user.id, user);
user.sendCommand('joinSuccess', {chanelName: this.name, id: user.id});
this.sendCommandToAllUsersExcept('userJoined', user.id, user);
this.serverGame.createPlayerForUser(user)
}
Channel.prototype.releaseUser = function(user){
@ -27,14 +29,18 @@ define(["Chuck/ServerGame"], function(ServerGame) {
}
}
Channel.prototype.sendCommandToAllUsersBut = function(command, options, user) {
Channel.prototype.sendCommandToAllUsersExcept = function(command, options, except_user) {
for(var id in this.users) {
if (id != user.id) {
if (id != except_user.id) {
this.users[id].sendCommand(command, options);
}
}
}
Channel.prototype.processGameCommandFromUser = function(command, user) {
console.log("not implemented processGameCommandFromUser: " + command + user);
}
return Channel;
});