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); } }
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); } }