Пример #1
0
        public void req_client_msg(int seq)
        {
            try
            {
                if (!end_point.connect_status)
                {
                    return;
                }
                JObject obj    = Msg_Parse.get_cmd_jsonobj(seq);
                uint    msg_id = uint.Parse(obj["msg_id"].ToString());
                if (msg_id < 5)
                {
                    player_log("小于5的命令号是系统命令号");
                    return;
                }
                Bit_Buffer buffer = new Bit_Buffer();
                Msg_Struct msg    = Struct_Manager.instance.get_send_msg_struct((int)msg_id);
                msg.scan(buffer, obj);

                if (-1 == msg.scan(buffer, obj) || msg == null)
                {
                    throw new Exception("命令参数错误");
                }
                end_point_.send_to_server(msg_id, buffer);
            }
            catch (Exception ex)
            {
                Log.debug_log(ex.Message);
            }
        }
Пример #2
0
        private void Button_Send_Click(object sender, EventArgs e)
        {
            if (!Game_Manager.instance.status())
            {
                Log.debug_log("请先连接服务器");
                return;
            }
            if (Text_Box_Cmd.Text == "")
            {
                Log.debug_log("请输入需要发送的数据");
                return;
            }

            Msg_Parse.parse_cmd_and_send_buffer(Text_Box_Cmd.Text);
        }
Пример #3
0
        static public void parse_cmd_and_send_buffer(string cmd)
        {
            Bit_Buffer buffer = new Bit_Buffer();

            try
            {
                JObject jsonobj    = null;
                Match   match      = Regex.Match(cmd, cmd_input_pattern_);
                string  cmd_string = match.Groups[0].ToString();
                if (cmd_string != "")
                {
                    string[] cmd_str = cmd_string.Split('@');
                    int      cmd_seq = int.Parse(cmd_str[1]);
                    Log.debug_log("脚本命令序列:" + cmd_seq.ToString() + " => " + Msg_Parse.parse_cmd_string(cmd_list_[cmd_seq]));
                    Game_Manager.instance.send_to_server(cmd_seq);
                    return;
                }
                else if (Regex.IsMatch(cmd, cmd_input_pattern2))
                {
                    int cmd_seq = int.Parse(cmd);
                    Log.debug_log("脚本命令序列:" + cmd_seq.ToString() + " => " + Msg_Parse.parse_cmd_string(cmd_list_[cmd_seq]));
                    Game_Manager.instance.send_to_server(cmd_seq);
                    return;
                }
                else
                {
                    string real_cmd = Msg_Parse.parse_cmd_string(cmd);
                    jsonobj = (JObject)JsonConvert.DeserializeObject(real_cmd);
                }
                uint msg_id = uint.Parse(jsonobj["msg_id"].ToString());
                if (msg_id < 5)
                {
                    Log.debug_log("小于5的命令号是系统命令号");
                    return;
                }
                Msg_Struct msg = Struct_Manager.instance.get_send_msg_struct((int)msg_id);

                if (-1 == msg.scan(buffer, jsonobj) || msg == null)
                {
                    throw new Exception("命令参数错误");
                }
                Game_Manager.instance.send_to_server(msg_id, buffer);
            }
            catch (Exception ex)
            {
                Log.debug_log(ex.Message);
            }
        }
Пример #4
0
        public int init_conf()
        {
            try
            {
                bool clear_map = true;
                init_conf_path();

                foreach (string path in conf_list_["msg_struct_path"])
                {
                    Log.debug_log("加载消息配置,path:" + path);
                    Struct_Manager.instance.load_config(path, clear_map);
                    if (clear_map)
                    {
                        clear_map = false;
                    }
                }

                clear_map = true;
                foreach (string path in conf_list_["cmd_list_path"])
                {
                    Log.debug_log("加载命令配置,path:" + path);
                    Msg_Parse.load_cmd_list(path, clear_map);
                    if (clear_map)
                    {
                        clear_map = false;
                    }
                }

                clear_map = true;
                foreach (string path in conf_list_["error_code_path"])
                {
                    Log.debug_log("加载错误号配置,path:" + path);
                    Error_Code.load_error_code(path, clear_map);
                    if (clear_map)
                    {
                        clear_map = false;
                    }
                }
                return(0);
            }
            catch (Exception ex)
            {
                Log.debug_log(ex.Message);
                return(-1);
            }
        }
Пример #5
0
 private void send_msg_tick()
 {
     req_client_msg(Msg_Parse.get_cmd_random());
 }