Deprecated? The only plus to this class is you define the command name once and then when you register it no need to specify the cmd name and if you send it no need to specify the command so in that sense it's a D.R.Y. thing Base class for all message data. Be sure to set the CmdName attribute
Пример #1
0
        public void SendCmd(MessageCmdData data) // Make it Ob's name is the message.
        {
            string     name   = MessageCmdDataNameDB.GetCmdName(data.GetType());
            MessageCmd msgCmd = new MessageCmd(name, data);

            m_server.SendCmd("client", m_id, msgCmd);
        }
Пример #2
0
 private void SendLowLevelCmd(string cmd, MessageCmdData data)
 {
     if (Connected)
     {
         Server.SendCmd(cmd, data, m_id);
     }
 }
Пример #3
0
        public void RegisterCreator(System.Type type)
        {
            string name = MessageCmdData.GetCmdName(type);

            if (name == null)
            {
                System.InvalidOperationException ex = new System.InvalidOperationException("missing CmdNameAttribute");
                throw ex;
            }
            m_creators[name] = new TypeBasedCreator(type);
        }
Пример #4
0
        public static string GetCmdName(System.Type type)
        {
            string name;

            if (!m_typeToCommandName.TryGetValue(type, out name))
            {
                name = MessageCmdData.GetCmdName(type);
                m_typeToCommandName[type] = name;
            }
            return(name);
        }
Пример #5
0
        public void RegisterCreator <T>() where T : new()
        {
            string name = MessageCmdData.GetCmdName(typeof(T));

            if (name == null)
            {
                System.InvalidOperationException ex = new System.InvalidOperationException("missing CmdNameAttribute");
                throw ex;
            }

            m_creators[name] = new TypedCreator <T>();
        }
Пример #6
0
 public void BroadcastCmdToGames(MessageCmdData data)
 {
     SendCmd("bcastToGames", data);
 }
Пример #7
0
 public void SendCmdToGame(string id, MessageCmdData data)
 {
     SendCmd("peer", data, id);
 }
Пример #8
0
 public void BroadcastCmd(MessageCmdData data)
 {
     SendCmd("broadcast", data);
 }
Пример #9
0
        // Only NetPlayer should call this.
        public void SendCmd(string cmd, MessageCmdData data, string id = "-1")
        {
            string name = HFTMessageCmdDataNameDB.GetCmdName(data.GetType());

            SendCmd(cmd, name, data, id);
        }
Пример #10
0
 public void Callback(GameServer server, MessageCmdData data)
 {
     server.QueueEvent(delegate() {
         m_handler((T)data);
     });
 }
Пример #11
0
 /// <summary>
 /// Sends a message to this player's phone
 /// </summary>
 /// <param name="data">The message. It must be derived from MessageCmdData and must have a
 /// CmdName attribute</param>
 /// <example>
 /// <code>
 /// </code>
 /// </example>
 public override void SendCmd(MessageCmdData data)
 {
     SendLowLevelCmd("client", data);
 }
Пример #12
0
 /// <summary>
 /// Sends a message to this player's phone
 /// </summary>
 /// <param name="data">The message. It must be derived from MessageCmdData and must have a
 /// CmdName attribute</param>
 /// <example>
 /// <code>
 /// </code>
 /// </example>
 public abstract void SendCmd(MessageCmdData data);
Пример #13
0
        public void SendEvent(MessageCmdData data)
        {
            string cmd = HFTMessageCmdDataNameDB.GetCmdName(data.GetType());

            SendEvent(cmd, data);
        }
Пример #14
0
        /// <summary>
        /// Sends a message to this player's phone
        /// </summary>
        /// <param name="data">The message. It must be derived from MessageCmdData and must have a
        /// CmdName attribute</param>
        /// <example>
        /// <code>
        /// </code>
        /// </example>
        public override void SendCmd(MessageCmdData data)
        {
            string cmd = HFTMessageCmdDataNameDB.GetCmdName(data.GetType());

            SendCmd(cmd, data);
        }
Пример #15
0
 /// <summary>
 /// Sends a message to this player's phone
 /// </summary>
 /// <param name="data">The message. It must be derived from MessageCmdData and must have a
 /// CmdName attribute</param>
 /// <example>
 /// <code>
 /// </code>
 /// </example>
 public override void SendCmd(MessageCmdData data)
 {
     SendLowLevelCmd("client", data);
 }
Пример #16
0
 public MessageCmd(string _cmd, MessageCmdData _data)
 {
     cmd  = _cmd;
     data = _data;
 }
        //Player requesting a new ID
        private void OnNeedID(MessageCmdData data)
        {
            Debug.Log("NEED ID!");
            int ID = PlayerIDManager.NewPlayer(this);
            myInfo = PlayerIDManager.playerInfos[PlayerIDManager.playerInfos.Count - 1];
            Debug.Log(m_color);
            myInfo.color = m_color;
            myInfo.id = PlayerIDManager.SessionID.ToString() + "|" + ID.ToString();
            //myInfo.copterSlot = getFreeCopterSlot();
            m_netPlayer.SendCmd("assignID", new MessageAssignID(myInfo.id));

            //m_netPlayer.SendCmd("restoreColor", new MessageRestoreColor(myInfo.color));
            //m_netPlayer.SendCmd("score", new MessageScored(0));
        }
Пример #18
0
 private void SendLowLevelCmd(string cmd, MessageCmdData data)
 {
     if (Connected)
     {
     Server.SendCmd(cmd, data, m_id);
     }
 }