mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
fixes #12 and added health
This commit is contained in:
parent
6c78c750f0
commit
d84fb20f90
7 changed files with 83 additions and 18 deletions
|
|
@ -28,8 +28,11 @@
|
|||
ProtocolHelper.applyCommand(message.data, self);
|
||||
});
|
||||
|
||||
NotificationCenter.on('sendControlCommandToAllUsers', this.sendControlCommandToAllUsers, this);
|
||||
NotificationCenter.on('sendControlCommandToAllUsersExcept', this.sendControlCommandToAllUsersExcept, this);
|
||||
NotificationCenter.on('broadcastControlCommand', this.broadcastControlCommand, this);
|
||||
NotificationCenter.on('broadcastControlCommandExcept', this.broadcastControlCommandExcept, this);
|
||||
|
||||
NotificationCenter.on('broadcastGameCommand', this.broadcastGameCommand, this);
|
||||
NotificationCenter.on('broadcastGameCommandExcept', this.broadcastGameCommandExcept, this);
|
||||
|
||||
console.checkpoint('channel ' + name + ' created');
|
||||
}
|
||||
|
|
@ -69,7 +72,7 @@
|
|||
|
||||
Channel.prototype.onReleaseUser = function (userId) {
|
||||
var user = this.users[userId];
|
||||
this.sendControlCommandToAllUsersExcept("userLeft", user.id, user);
|
||||
this.broadcastControlCommandExcept("userLeft", user.id, user);
|
||||
NotificationCenter.trigger('user/left', user);
|
||||
delete this.users[user.id];
|
||||
}
|
||||
|
|
@ -77,13 +80,13 @@
|
|||
|
||||
// Sending commands
|
||||
|
||||
Channel.prototype.sendControlCommandToAllUsers = function (command, options) {
|
||||
Channel.prototype.broadcastControlCommand = function (command, options) {
|
||||
for(var id in this.users) {
|
||||
this.users[id].sendControlCommand(command, options);
|
||||
}
|
||||
}
|
||||
|
||||
Channel.prototype.sendControlCommandToAllUsersExcept = function (command, options, exceptUser) {
|
||||
Channel.prototype.broadcastControlCommandExcept = function (command, options, exceptUser) {
|
||||
for(var id in this.users) {
|
||||
if (id != exceptUser.id) {
|
||||
this.users[id].sendControlCommand(command, options);
|
||||
|
|
@ -91,6 +94,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
Channel.prototype.broadcastGameCommand = function (command, options) {
|
||||
this.broadcastControlCommand("gameCommand", ProtocolHelper.encodeCommand(command, options));
|
||||
}
|
||||
|
||||
Channel.prototype.broadcastGameCommandExcept = function (command, options, exceptUser) {
|
||||
this.broadcastControlCommandExcept("gameCommand", ProtocolHelper.encodeCommand(command, options), exceptUser);
|
||||
}
|
||||
|
||||
return Channel;
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue