コード例 #1
0
 private void messageReceived(string gateway, UserModel user, string eventChannel, ChannelMessage content)
 {
     if (users.ContainsKey(user.UserName)) {
         var u = users[user.UserName];
         u.Socket.Emit("Client.Message", new SocketClientMessageModel(user, eventChannel, content));
     }
 }
コード例 #2
0
        private void messageReceived(string name, UserModel user, ChannelMessage message)
        {
            user.Gateway = name;

            if (channels[message.Channel] != null)
                channels[message.Channel](user, message);
        }
コード例 #3
0
        public void SendMessage(string channel, ChannelMessage message)
        {
            var pusher = (QueuePusher) qpCollection.GetByChannel(channel);

            if (pusher == null) {
                Global.Console.Log(channel + " No Existy");
                return;
            }

            pusher.Message(channel, Name, message);
        }
コード例 #4
0
 public SocketClientMessageModel(UserModel user, string channel, ChannelMessage content)
 {
     User = user;
     Channel = channel;
     Content = content;
 }
コード例 #5
0
 public GatewayMessageModel(string channel, ChannelMessage content)
 {
     Channel = channel;
     Content = content;
 }
コード例 #6
0
        /// <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));
        }
コード例 #7
0
 private void gameServerMessage(string name, UserModel user, ChannelMessage content)
 {
     switch (content.Channel) {
         case PlayerJoinMessage.MessageChannel:
             var c = (PlayerJoinMessage) content;
             var lampPlayer = new LampPlayer(user);
             myGame.MakePlayerActive(lampPlayer);
             PushPlayerMessage(lampPlayer, new GameServerAcceptMessage() {GameServer = myGameServerInfo.GameServerName});
             break;
     }
 }
コード例 #8
0
 private void gameServerIndexMessage(string name, UserModel user, ChannelMessage content)
 {
     LampMessage message = (LampMessage) content;
     message.User = (LampPlayer) user;
     myGame.ReceiveMessage(message);
 }
コード例 #9
0
 public void EmitAll(IEnumerable<LampPlayer> players, ChannelMessage val)
 {
     foreach (var player in players) {
         myGameServerInfo.QueueManager.SendMessage(player, player.Gateway, val);
     }
 }
コード例 #10
0
 public void Emit(LampPlayer player, ChannelMessage val)
 {
     myGameServerInfo.QueueManager.SendMessage(player, player.Gateway, val);
 }
コード例 #11
0
 private void PushPlayerMessage(LampPlayer user, ChannelMessage message)
 {
     myGameServerInfo.QueueManager.SendMessage(user, user.Gateway, message);
 }
コード例 #12
0
 private void gameServerProductMessage(string name, UserModel user, ChannelMessage content)
 {
     var player = (LampPlayer) user;
 }
コード例 #13
0
 public void Message(string channel, string name, ChannelMessage content)
 {
     var message = new QueueMessage(name, null, content);
     var value = Json.Stringify(message, Help.Sanitize);
     client1.RPush(channel, value); //todo:maybe sanitize
 }
コード例 #14
0
 public QueueMessage(string name, UserModel user, ChannelMessage content)
 {
     Name = name;
     User = user;
     Content = content;
 }
コード例 #15
0
 public void Emit(ChannelMessage content)
 {
     GatewaySocket.Emit("Gateway.Message", new GatewayMessageModel(content.GatewayChannel, content));
 }