mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
gameCommand implementation
This commit is contained in:
parent
6219a82fbd
commit
c4c48ab821
10 changed files with 62 additions and 39 deletions
|
|
@ -84,6 +84,10 @@ function (User, Channel, PipeToChannel, NotificationCenter) {
|
|||
NotificationCenter.on('user/left', function (user) {
|
||||
channelPipe.send('channel', { releaseUser: user.id });
|
||||
}, this);
|
||||
|
||||
NotificationCenter.on('user/gameCommand', function (userId, data) {
|
||||
channelPipe.sendToUser(userId, data);
|
||||
}, this);
|
||||
|
||||
return channelPipe;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -35,6 +35,15 @@ function (NotificationCenter, childProcess) {
|
|||
this.channelPipe.send(message);
|
||||
}
|
||||
|
||||
PipeToChannel.prototype.sendToUser = function (id, data) {
|
||||
var message = {
|
||||
recipient: "user/" + id,
|
||||
data: data
|
||||
}
|
||||
|
||||
this.channelPipe.send(message);
|
||||
}
|
||||
|
||||
PipeToChannel.prototype.onMessage = function (message) {
|
||||
NotificationCenter.trigger(message.recipient + '/message', message.data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,10 +54,7 @@ function (Parent, ProtocolHelper, NotificationCenter) {
|
|||
break;
|
||||
|
||||
case 'gameCommand':
|
||||
for(var gameCommand in options) {
|
||||
//NotificationCenter.trigger("processGameCommandFromUser", [gameCommand, options[gameCommand], this]);
|
||||
//this.channel.processGameCommandFromUser(gameCommand, options[gameCommand], this);
|
||||
}
|
||||
NotificationCenter.trigger("user/gameCommand", this.id, options);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue