/// <summary> /// 查询信息 /// </summary> public static void QueryDBEvent(long char_idx, DBID db_id, Action <List <DBEventInfo> > callback) { List <DBEventInfo> list = new List <DBEventInfo>(); ByteArray by = DBUtils.AllocDBArray(); string sql = "call SP_DB_EVENT_LOAD(" + char_idx + ")"; DBManager.Instance.GetDB(eDBType.Game, db_id.game_id).Query(sql, (reader) => { if (reader.HasRows) { while (reader.Read()) { DBEventInfo info = new DBEventInfo(); info.event_idx = reader.GetInt64(0); info.target_char_idx = reader.GetInt64(1); info.source_char_idx = reader.GetInt64(2); info.event_type = (eDBEventType)reader.GetByte(3); //内容 by.Clear(); long len = reader.GetBytes(4, 0, null, 0, int.MaxValue); reader.GetBytes(4, 0, by.Buffer, 0, (int)len); by.WriteEmpty((int)len); info.bin_content.Read(by); list.Add(info); } } callback(list); }); }
/// <summary> /// 添加事件 /// </summary> public static void InsertDBEvent(DBEventInfo info, DBID db_id) { string sql = "call SP_DB_EVENT_CREATE(" + info.target_char_idx + "," + info.source_char_idx + "," + (byte)info.event_type + "," + "@i_bin_content);"; ByteArray by = DBUtils.AllocDBArray(); info.bin_content.Write(by); List <MySqlParameter> param = new List <MySqlParameter>(); MySqlParameter p = Database.MakeMysqlParam("@i_bin_content", MySqlDbType.Blob, by.GetBuffer(), by.Available); param.Add(p); DBManager.Instance.GetDB(eDBType.Game, db_id.game_id).Execute(sql, param); }
public void Start() { DataManager.Instance.LoadAll(); DBManager.Instance.Start(ServerConfig.db_info.db_list); ServerNetManager.Instance.Connect2WorldServer(ServerConfig.net_info.ws_ip, ServerConfig.net_info.ws_port); DBID db_id = new DBID(); db_id.game_id = 100; DBEventInfo e_info = new DBEventInfo(); e_info.target_char_idx = 10000000002; e_info.source_char_idx = 10000000003; e_info.event_type = eDBEventType.Test; e_info.bin_content.bin_normal_content.data = "测试了"; SQLDBEventHandle.InsertDBEvent(e_info, db_id); Framework.Instance.MainLoop(); }
/// <summary> /// 处理db事件 /// </summary> /// <param name="info"></param> public bool HandleDBEvent(DBEventInfo info) { return(true); }