/// <summary>
        ///     the message received from the gameserver
        /// </summary>
        /// <param name="gatewayName">This will either be the gateway's name (gateway94) or just "gateway" meaning it was sent to all gateways and you are the one to pop it from the queue</param>
        /// <param name="channel">the queue channel, generally not needed</param>
        /// <param name="user"></param>
        /// <param name="content"></param>
        private void messageReceived(string gatewayName, UserModel user, ChannelMessage content)
        {
            if (users.ContainsKey(user.UserName)) {
                var u = users[user.UserName];

                if (content.Channel == "GameServer.Accept") {
            //if the gamserver has accepted the player, tell him he has joined

                    var message = ( (GameServerAcceptMessage) content );
                    u.GameServer = message.GameServer;

                    SocketClientMessageModel socketClientMessageModel = new SocketClientMessageModel(user, "GameServer.Joined", null);
                    u.Socket.Emit("Client.Message", socketClientMessageModel);
                } else {
            //otherwise this is a normal message, just forward it along.

                    SocketClientMessageModel socketClientMessageModel = new SocketClientMessageModel(user, content.Channel, content);
                    u.Socket.Emit("Client.Message", socketClientMessageModel);
                }
            } else throw new Exception(string.Format("client {0} no found so failure", user.UserName));
        }
示例#2
0
 private void receiveMessage(SocketClientMessageModel data)
 {
     channels[data.Channel](data.User,data.Content);
 }