This commit is contained in:
Jeena 2014-02-24 19:26:31 +01:00
parent 695008afd8
commit aa4535cb0c
10 changed files with 73 additions and 32 deletions

View file

@ -12,6 +12,7 @@ function(Parent, NotificationCenter, ProtocolHelper, ProtocolParser) {
this.channel = channel;
this.player = null;
this.isReady = false;
var self = this;
NotificationCenter.on('user/joined', function(user) { // FIXME: use sendToAllUsersExcept instead
@ -51,6 +52,7 @@ function(Parent, NotificationCenter, ProtocolHelper, ProtocolParser) {
if(command.hasOwnProperty("resetLevel")) {
NotificationCenter.trigger("user/resetLevel", this.id);
} else if(command.hasOwnProperty("clientReady")) {
this.isReady = true;
NotificationCenter.trigger("user/clientReady", this.id);
} else {
this.player.playerController.applyCommand(command);
@ -69,8 +71,10 @@ function(Parent, NotificationCenter, ProtocolHelper, ProtocolParser) {
};
User.prototype.sendGameCommand = function(command, options) {
var data = ProtocolHelper.encodeCommand(command, options);
this.sendControlCommand("gameCommand", data);
if(this.isReady) {
var data = ProtocolHelper.encodeCommand(command, options);
this.sendControlCommand("gameCommand", data);
}
};