diff --git a/lib/Server/Channel.js b/lib/Server/Channel.js index 29343e0..218a62f 100644 --- a/lib/Server/Channel.js +++ b/lib/Server/Channel.js @@ -4,7 +4,13 @@ define(["Chuck/ServerGame"], function(ServerGame) { this.name = name; this.users = {}; this.serverGame = this.factory.new(ServerGame, this); + console.log("server game " + this.serverGame); this.serverGame.loadLevel("default.json"); + + var self = this; + this.notificationCenter.on("processGameCommandFromUser", function(topic, args) { + self.processGameCommandFromUser.apply(self, args); + }); } Channel.validateName = function(name){ diff --git a/lib/Server/Coordinator.js b/lib/Server/Coordinator.js index 3a71f80..c88816a 100644 --- a/lib/Server/Coordinator.js +++ b/lib/Server/Coordinator.js @@ -35,6 +35,9 @@ define(["Server/User", "Server/Channel", "Server/Factory"], function(User, Chann this.channels[channelName] = channel; } + user.notificationCenter = channel.notificationCenter; + user.factory = channel.factory; + channel.addUser(user); user.setChannel(channel); diff --git a/lib/Server/User.js b/lib/Server/User.js index 737d9f3..792e4aa 100644 --- a/lib/Server/User.js +++ b/lib/Server/User.js @@ -56,7 +56,8 @@ define(["Protocol/Helper"], function(ProtocolHelper) { case 'gameCommand': for(var gameCommand in options) { - this.channel.processGameCommandFromUser(gameCommand, options[gameCommand], this); + this.notificationCenter.trigger("processGameCommandFromUser", [gameCommand, options[gameCommand], this]); + //this.channel.processGameCommandFromUser(gameCommand, options[gameCommand], this); } break;