mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
ground work for different users on server and players on client
This commit is contained in:
parent
e37d1eeb2e
commit
2cb401bbd3
9 changed files with 122 additions and 54 deletions
|
|
@ -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;
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue