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
ファイル: NetPlayer.cs プロジェクト: aaronyuen2/earthDefender
 /// <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;
 }
コード例 #17
0
        //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);
     }
 }