mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
added debug information when users join
This commit is contained in:
parent
bffb16e77c
commit
e37d1eeb2e
2 changed files with 25 additions and 2 deletions
|
|
@ -52,8 +52,14 @@ define(["Protocol/Helper", "Chuck/ClientGame"], function(ProtocolHelper, ClientG
|
||||||
Networker.prototype.onJoinSuccess = function(channelName) {
|
Networker.prototype.onJoinSuccess = function(channelName) {
|
||||||
this.clientGame = new ClientGame(this);
|
this.clientGame = new ClientGame(this);
|
||||||
this.clientGame.loadLevel("default.json")
|
this.clientGame.loadLevel("default.json")
|
||||||
|
console.log("Joined " + channelName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Networker.prototype.onUserJoined = function(userId) {
|
||||||
|
//this.clientGame.userJoined(userId);
|
||||||
|
console.log("User " + userId + " joined");
|
||||||
|
};
|
||||||
|
|
||||||
Networker.prototype.processControlCommand = function(command, options){
|
Networker.prototype.processControlCommand = function(command, options){
|
||||||
switch(command) {
|
switch(command) {
|
||||||
case 'joinSuccess':
|
case 'joinSuccess':
|
||||||
|
|
@ -64,6 +70,10 @@ define(["Protocol/Helper", "Chuck/ClientGame"], function(ProtocolHelper, ClientG
|
||||||
this.clientGame.processGameCommand(options);
|
this.clientGame.processGameCommand(options);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'userJoined':
|
||||||
|
this.onUserJoined(options);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,27 @@ define(["Chuck/ServerGame"], function(ServerGame) {
|
||||||
|
|
||||||
Channel.prototype.addUser = function(user){
|
Channel.prototype.addUser = function(user){
|
||||||
this.users[user.id] = user;
|
this.users[user.id] = user;
|
||||||
|
|
||||||
|
user.sendCommand('joinSuccess', this.name);
|
||||||
|
this.sendCommandToAllUsersBut('userJoined', user.id, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel.prototype.releaseUser = function(user){
|
Channel.prototype.releaseUser = function(user){
|
||||||
delete this.users[user.id];
|
delete this.users[user.id];
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel.prototype.sendToAllUsers = function(package) {
|
Channel.prototype.sendCommandToAllUsers = function(command, options) {
|
||||||
console.log("not implemented sendToAllUsers: " + JSON.stringify(package))
|
for(var id in this.users) {
|
||||||
|
this.users[id].sendCommand(command, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Channel.prototype.sendCommandToAllUsersBut = function(command, options, user) {
|
||||||
|
for(var id in this.users) {
|
||||||
|
if (id != user.id) {
|
||||||
|
this.users[id].sendCommand(command, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Channel;
|
return Channel;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue