Пример #1
0
        /// <summary>
        /// 保存到db
        /// </summary>
        public void Save()
        {
            SQLCharHandle.SaveCharacterInfo(m_ss_data);

            m_is_dirty       = false;
            m_last_save_time = Time.timeSinceStartup;
        }
Пример #2
0
        /// <summary>
        /// 保存到db
        /// </summary>
        public void Save()
        {
            SQLCharHandle.SaveCharacterInfo(m_player_data);

            m_is_dirty       = false;
            m_last_save_time = Time.second_time;
        }
Пример #3
0
        /// <summary>
        /// 保存到db
        /// </summary>
        public void Save()
        {
            SQLCharHandle.SaveCharacterInfo(m_db_id, m_unit_attr.player_info);

            m_is_dirty       = false;
            m_last_save_time = Time.timeSinceStartup;
        }
Пример #4
0
 /// <summary>
 /// 同步好友最新数据:玩家上线时触发
 /// </summary>
 public void SyncDataFromUnit()
 {
     foreach (var obj in m_relations)
     {
         RelationInfo info = obj.Value;
         Unit         unit = UnitManager.Instance.GetUnitByIdx(info.char_idx);
         if (unit == null)
         {//取db离线数据
             long            target_char_idx = info.char_idx;
             PlayerInfoForGL data            = CommonObjectPools.Spawn <PlayerInfoForGL>();
             SQLCharHandle.QueryCharacterInfo(target_char_idx, data, (ret) =>
             {
                 if (ret)
                 {
                     RelationInfo db_info;
                     if (m_relations.TryGetValue(target_char_idx, out db_info))
                     {
                         db_info.Copy(data);
                     }
                 }
                 CommonObjectPools.Despawn(data);
                 this.SyncRelation2SS(target_char_idx);
             });
         }
         else
         {
             info.Copy(unit.player_data);
             this.SyncRelation2SS(info.char_idx);
         }
     }
 }
Пример #5
0
 /// <summary>
 /// 从db加载数据
 /// </summary>
 /// <param name="_char_idx"></param>
 /// <returns></returns>
 public void Load(long _char_idx, Action <bool> callback)
 {
     m_char_idx = _char_idx;
     SQLCharHandle.QueryCharacterInfo(m_char_idx, m_ss_data, is_load =>
     {
         callback(is_load);
     });
 }
Пример #6
0
        /// <summary>
        /// 进入游戏
        /// </summary>
        private void OnEnterGame(PacketBase packet)
        {
            gs2ss.EnterGame msg        = packet as gs2ss.EnterGame;
            ClientUID       client_uid = msg.client_uid;
            InterServerID   server_uid = msg.server_uid;

            UnitManager.Instance.AddSession(client_uid);

            if (!UnitManager.Instance.HasUnit(msg.char_idx))
            {
                DBID db_id = new DBID();
                db_id.game_id = ServerConfig.GetDBByAccountIdx(msg.account_idx, eDBType.Game);
                PlayerInfoForSS ss_data = CommonObjectPools.Spawn <PlayerInfoForSS>();
                SQLCharHandle.QueryCharacterInfo(msg.char_idx, db_id, ss_data, is_load =>
                {
                    if (is_load && UnitManager.Instance.HadSession(client_uid))
                    {//读取玩数据,有可能已经退出
                        //创建玩家
                        Player player     = new Player();
                        player.client_uid = client_uid;
                        player.LoadData(ss_data);
                        UnitManager.Instance.AddUnit(player);

                        //告诉gs成功进入游戏
                        ss2gs.EnterGame rep_gs_msg = PacketPools.Get(ss2gs.msg.ENTER_GAME) as ss2gs.EnterGame;
                        rep_gs_msg.server_uid      = server_uid;
                        rep_gs_msg.client_uid      = client_uid;
                        rep_gs_msg.char_idx        = ss_data.char_idx;
                        ServerNetManager.Instance.Send(server_uid.gs_uid, rep_gs_msg);

                        //告诉ws
                        ss2ws.LoginClient rep_ws_msg = PacketPools.Get(ss2ws.msg.LOGIN_CLIENT) as ss2ws.LoginClient;
                        rep_ws_msg.server_uid        = server_uid;
                        rep_ws_msg.client_uid        = client_uid;
                        rep_ws_msg.data.Copy(ss_data);
                        ServerNetManager.Instance.Send2WS(rep_ws_msg);

                        //告诉gl
                        ss2gl.LoginClient rep_gl_msg = PacketPools.Get(ss2gl.msg.LOGIN_CLIENT) as ss2gl.LoginClient;
                        rep_gl_msg.server_uid        = server_uid;
                        rep_gl_msg.data.Copy(ss_data);
                        ServerNetManager.Instance.Send2GL(rep_gl_msg);

                        //告诉客户端角色基础信息
                        ss2c.CharacterInfo rep_msg = PacketPools.Get(ss2c.msg.CHARACTER_INFO) as ss2c.CharacterInfo;
                        rep_msg.data.Copy(ss_data);
                        ServerNetManager.Instance.SendProxy(client_uid, rep_msg, false);

                        //初始化内部逻辑
                        player.OnFirstEnter();
                    }
                    CommonObjectPools.Despawn(ss_data);
                });
            }
        }
 /// <summary>
 /// 预加载数据
 /// </summary>
 /// <param name="load_max"></param>
 private void PreLoadPlayer(uint load_max)
 {
     SQLCharHandle.QueryCharForPreload(load_max, list =>
     {
         Log.Info("预加载玩家数量:" + list.Count);
         foreach (var char_idx in list)
         {
             LoadPlayer(char_idx, null);
         }
     }
                                       );
 }
Пример #8
0
        /// <summary>
        /// 角色列表
        /// </summary>
        private void OnEnumCharacterList(PacketBase packet)
        {
            gs2ss.EnumCharacter msg        = packet as gs2ss.EnumCharacter;
            ClientUID           client_uid = msg.client_uid;

            SQLCharHandle.QueryCharacterList(msg.account_idx, new DBID(msg.game_db_id), (data) =>
            {
                ss2c.EnumCharacter rep_msg = PacketPools.Get(ss2c.msg.ENUM_CHAR) as ss2c.EnumCharacter;
                foreach (var char_data in data)
                {
                    rep_msg.list.Add(char_data);
                }
                ServerNetManager.Instance.SendProxy(client_uid, rep_msg);
            }
                                             );
        }
Пример #9
0
        /// <summary>
        /// 创建角色
        /// </summary>
        private void OnCreateCharacter(PacketBase packet)
        {
            gs2ss.CreateCharacter msg = packet as gs2ss.CreateCharacter;

            CreateCharacterInfo create_info = new CreateCharacterInfo();

            create_info.spid      = msg.spid;
            create_info.ws_id     = ServerNetManager.Instance.srv_realm_idx;
            create_info.ss_id     = 0;
            create_info.fs_id     = 0;
            create_info.char_idx  = IdSharedManager.Instance.GetNextCharIdx();
            create_info.char_name = msg.name;
            create_info.char_type = (byte)msg.flags;

            long   account_idx = msg.account_idx;
            ushort gs_uid      = msg.server_uid.gs_uid;

            SQLCharHandle.CreateCharacter(account_idx, new DBID(msg.game_db_id), create_info, (res) =>
            {
                eCreateCharResult result = eCreateCharResult.E_FAILED_COMMONERROR;
                if (create_info.char_idx == res)
                {
                    result = eCreateCharResult.E_SUCCESS;
                }
                else
                {
                    switch (res)
                    {
                    case 0: result = eCreateCharResult.E_FAILED_INTERNALERROR; break;

                    case 1: result = eCreateCharResult.E_FAILED_CHARCOUNTLIMIT; break;

                    case 2: result = eCreateCharResult.E_FAILED_INVALIDPARAM_REPEATEDNAME; break;

                    case 3: result = eCreateCharResult.E_FAILED_COMMONERROR; break;
                    }
                }

                ss2gs.CreateCharacter rep_msg = PacketPools.Get(ss2gs.msg.CREATE_CHARACTER) as ss2gs.CreateCharacter;
                rep_msg.result      = result;
                rep_msg.account_idx = account_idx;
                rep_msg.char_idx    = create_info.char_idx;
                ServerNetManager.Instance.Send(gs_uid, rep_msg);
            }
                                          );
        }
        private void QueryMaxCharIdx(ushort game_db_id)
        {
            DBID db_id = new DBID();

            db_id.game_id = game_db_id;
            SQLCharHandle.QueryMaxCharIdx(ServerConfig.net_info.server_realm, db_id, max_id =>
            {
                long next_char_idx = max_id;
                if (next_char_idx == 0)
                {//没有数据,则初始化起始值
                    next_char_idx = ServerConfig.net_info.server_realm;
                    next_char_idx = next_char_idx * GlobalID.INIT_CHAR_IDX;
                }
                m_max_char_idx.Add(game_db_id, next_char_idx);
                Log.Info("next_char_idx " + game_db_id + " :" + next_char_idx);
            });
        }
Пример #11
0
 /// <summary>
 /// 写邮件
 /// </summary>
 public void HandleWriteMail(MailWriteInfo info)
 {
     if (info.receiver.IsIdxValid())
     {
         ProcessWrite(info);
     }
     else
     {
         if (String.IsNullOrEmpty(info.receiver.char_name))
         {
             Log.Debug("错误的收件人name:" + info.receiver.char_name);
             return;
         }
         Player recv_player = UnitManager.Instance.GetPlayerByName(info.receiver.char_name);
         if (recv_player != null)
         {
             info.receiver.char_idx = recv_player.char_idx;
             ProcessWrite(info);
         }
         else
         {//需要查db
             Player player = UnitManager.Instance.GetUnitByIdx(m_char_idx) as Player;
             if (player == null)
             {
                 return;
             }
             SQLCharHandle.QueryCharacterInfoByName(info.receiver.char_name, player.db_id, (ret, data) =>
             {//收件人必须是在同一个数据库
                 if (ret && m_char_idx > 0)
                 {
                     info.receiver.char_idx = data.char_idx;
                     ProcessWrite(info);
                 }
                 else
                 {//告诉客户端发送失败
                     ss2c.MailCommand msg_client = PacketPools.Get(ss2c.msg.MAIL_COMMAND) as ss2c.MailCommand;
                     msg_client.mail_idx         = 0;
                     msg_client.command_type     = eMailCommandType.WRITE_MAIL;
                     msg_client.error_type       = eMailCommandError.RECIPIENT_NOT_FOUND;
                     ServerNetManager.Instance.SendProxy(player.client_uid, msg_client);
                 }
             });
         }
     }
 }
 public void InitNextCharIdx()
 {
     if (m_srv_realm_idx > 0)
     {
         SQLCharHandle.QueryMaxCharIdx(m_srv_realm_idx, max_id =>
         {
             m_next_char_idx = max_id;
             if (m_next_char_idx == 0)
             {//没有数据
                 m_next_char_idx = m_srv_realm_idx;
                 m_next_char_idx = m_next_char_idx * 10000000000;
             }
             Log.Info("next_char_idx:" + m_next_char_idx);
         });
     }
     else
     {
         Log.Warning("未连接上世界服");
     }
 }
Пример #13
0
        /// <summary>
        /// 创建角色
        /// </summary>
        private void OnCreateCharacter(PacketBase packet)
        {
            ss2db.CreateCharacter msg = packet as ss2db.CreateCharacter;

            InterServerID       server_uid  = msg.server_uid;
            ClientUID           client_uid  = msg.client_uid;
            CreateCharacterInfo create_info = msg.data;

            create_info.char_idx = ServerNetManager.Instance.GetNextCharIdx();

            SQLCharHandle.CreateCharacter(msg.account_idx, create_info, (res) =>
            {
                eCreateCharResult result = eCreateCharResult.E_FAILED_COMMONERROR;
                if (create_info.char_idx == res)
                {
                    result = eCreateCharResult.E_SUCCESS;
                }
                else
                {
                    switch (res)
                    {
                    case 0: result = eCreateCharResult.E_FAILED_INTERNALERROR; break;

                    case 1: result = eCreateCharResult.E_FAILED_CHARCOUNTLIMIT; break;

                    case 2: result = eCreateCharResult.E_FAILED_INVALIDPARAM_REPEATEDNAME; break;

                    case 3: result = eCreateCharResult.E_FAILED_COMMONERROR; break;
                    }
                }

                db2ss.CreateCharacter rep_msg = PacketPools.Get(db2ss.msg.CREATE_CHARACTER) as db2ss.CreateCharacter;
                rep_msg.server_uid            = server_uid;
                rep_msg.client_uid            = client_uid;
                rep_msg.char_idx  = create_info.char_idx;
                rep_msg.char_name = create_info.char_name;
                rep_msg.result    = result;
                this.Send(rep_msg);
            }
                                          );
        }
Пример #14
0
        /// <summary>
        /// 角色列表
        /// </summary>
        private void OnEnumCharacter(PacketBase packet)
        {
            ss2db.EnumCharacter msg = packet as ss2db.EnumCharacter;

            InterServerID server_uid = msg.server_uid;
            ClientUID     client_uid = msg.client_uid;

            SQLCharHandle.QueryCharacterList(msg.account_idx, (data) =>
            {
                db2ss.EnumCharacter rep_msg = PacketPools.Get(db2ss.msg.ENUM_CHAR) as db2ss.EnumCharacter;
                rep_msg.server_uid          = server_uid;
                rep_msg.client_uid          = client_uid;
                foreach (var char_data in data)
                {
                    rep_msg.list.Add(char_data);
                }
                rep_msg.result = eEnumCharResult.E_SUCCESS;
                this.Send(rep_msg);
            }
                                             );
        }
Пример #15
0
 /// <summary>
 /// 写邮件
 /// </summary>
 public void HandleWriteMail(MailWriteInfo info)
 {
     if (info.receiver.IsIdxValid())
     {
         ProcessWrite(info);
     }
     else
     {
         if (String.IsNullOrEmpty(info.receiver.char_name))
         {
             Log.Warning("错误的收件人name:" + info.receiver.char_name);
             return;
         }
         Player recv_player = UnitManager.Instance.GetPlayerByName(info.receiver.char_name);
         if (recv_player != null)
         {
             info.receiver.char_idx = recv_player.char_idx;
             ProcessWrite(info);
         }
         else
         {//需要查db
             Player player = UnitManager.Instance.GetUnitByIdx(m_char_idx) as Player;
             if (player == null)
             {
                 return;
             }
             SQLCharHandle.QueryCharacterInfoByName(info.receiver.char_name, player.db_id, (ret, data) =>
             {
                 if (ret && m_char_idx > 0)
                 {
                     info.receiver.char_idx = data.char_idx;
                     ProcessWrite(info);
                 }
             });
         }
     }
 }
        private void CreateOneUser(long account_idx, long char_idx)
        {
            if (!m_active || account_idx > m_pressure_info.end_account)
            {
                return;
            }

            CreateCharacterInfo create_info = new CreateCharacterInfo();

            create_info.spid      = 0;
            create_info.ws_id     = 0;
            create_info.ss_id     = 0;
            create_info.fs_id     = 0;
            create_info.char_idx  = char_idx;
            create_info.char_name = "test" + account_idx;
            create_info.char_type = (byte)(MathUtils.Rand_Sign() == 1 ? eSexType.BOY : eSexType.GIRL);

            SQLCharHandle.CreateCharacter(account_idx, create_info, (res) =>
            {
                if (create_info.char_idx != res)
                {
                    Log.Error("创建角色失败,账号:" + account_idx + ", error:" + res.ToString());
                }
                EventController.TriggerEvent(ClientEventID.CREATE_PROGRESS, (int)(account_idx - m_pressure_info.start_account), (int)(m_pressure_info.end_account - m_pressure_info.start_account));
                if (account_idx + 1 > m_pressure_info.end_account)
                {
                    EventController.TriggerEvent(ClientEventID.CREATE_COMPLETE);
                    this.Stop();
                }
                else
                {
                    this.CreateOneUser(account_idx + 1, char_idx + 1);
                }
            }
                                          );
        }
Пример #17
0
        /// <summary>
        /// 添加关系
        /// </summary>
        public void AddRelationCommand(RelationAddTarget target_id, eRelationFlag flag, string message)
        {
            //超过上限
            if (IsRelationFull(flag))
            {
                return;
            }

            //不在线了
            Unit player = UnitManager.Instance.GetUnitByIdx(m_char_idx);

            if (player == null)
            {
                return;
            }

            //判断是否已经存在关系,另外防止添加自己为好友
            if (target_id.type == eRelationAddType.Idx)
            {
                if (target_id.char_idx == m_char_idx)
                {
                    return;
                }
                RelationInfo relation_info;
                if (m_relations.TryGetValue(target_id.char_idx, out relation_info) && relation_info.flags == flag)
                {
                    return;
                }
            }
            else
            {
                if (target_id.char_name == player.char_name)
                {
                    return;
                }
                foreach (var relation_info in m_relations)
                {
                    if (relation_info.Value.char_name == target_id.char_name && relation_info.Value.flags == flag)
                    {
                        return;
                    }
                }
            }

            //如果是根据名称加好友,必须在缓存里面能查找到玩家数据
            Unit target_player = null;

            if (target_id.type == eRelationAddType.Idx)
            {
                target_player = UnitManager.Instance.GetUnitByIdx(target_id.char_idx);
            }
            else if (target_id.type == eRelationAddType.Name)
            {
                target_player = UnitManager.Instance.GetUnitByName(target_id.char_name);
                if (target_player == null)
                {
                    return;//TODO:后期如果有需求,可以查表
                }
                else
                {
                    target_id.char_idx = target_player.char_idx;
                }
            }

            //拉黑直接处理,如果有好友关系,需要先去掉好友
            if (flag == eRelationFlag.Block)
            {
                RelationInfo relation_info;
                if (m_relations.TryGetValue(target_id.char_idx, out relation_info))
                {
                    relation_info.flags = eRelationFlag.Block;
                    this.SyncRelation2SS(target_id.char_idx);
                }
                else
                {
                    if (target_player == null)
                    {
                        PlayerInfoForGL data = CommonObjectPools.Spawn <PlayerInfoForGL>();
                        SQLCharHandle.QueryCharacterInfo(target_id.char_idx, data, (ret) =>
                        {
                            if (ret && m_char_idx > 0)
                            {
                                relation_info = CommonObjectPools.Spawn <RelationInfo>();
                                relation_info.Copy(data);
                                relation_info.flags = flag;
                                this.AddRelation(relation_info);
                                this.SyncRelation2SS(target_id.char_idx);
                            }
                            CommonObjectPools.Despawn(data);
                        });
                    }
                    else
                    {
                        relation_info = CommonObjectPools.Spawn <RelationInfo>();
                        relation_info.Copy(target_player.player_data);
                        relation_info.flags = flag;
                        this.AddRelation(relation_info);
                        this.SyncRelation2SS(target_id.char_idx);
                    }
                }
            }

            //添加到db,需要先判断数据库是否已经有写入过,防止重复写入
            //注:如果赠送可以同时存在的话,这里需要屏蔽赠送类型
            SQLRelationHandle.QueryExistsRelationEvent(m_char_idx, target_id.char_idx, flag, (event_idx) =>
            {
                if (event_idx == 0 && m_char_idx > 0)
                {//保存事件
                    RelationEventInfo e_info = new RelationEventInfo();
                    e_info.target_char_idx   = target_id.char_idx;
                    e_info.source_char_idx   = m_char_idx;
                    e_info.event_type        = eRelationEvent.Add;
                    e_info.bin_content.bin_add_content.char_name = player.char_name;
                    e_info.bin_content.bin_add_content.message   = message;
                    e_info.bin_content.bin_add_content.flag      = flag;
                    SQLRelationHandle.InsertRelationEvent(e_info);

                    //立刻通知接受者
                    this.BroadcastEvent(e_info.target_char_idx, e_info.event_type);
                }
            });
        }
Пример #18
0
        /// <summary>
        /// 申请反馈
        /// </summary>
        public void ApplyRelationCommand(long event_idx, long target_char_idx, eRelationApplyCmd cmd)
        {
            //是否存在申请事件
            RelationEventInfo relation_evt;

            if (!m_relation_events.TryGetValue(event_idx, out relation_evt))
            {
                return;
            }

            switch (relation_evt.event_type)
            {
            case eRelationEvent.Add:
            {
                eRelationFlag flag = relation_evt.bin_content.bin_add_content.flag;
                if (cmd == eRelationApplyCmd.Agree)
                {
                    //超过上限
                    if (IsRelationFull(flag))
                    {
                        SQLRelationHandle.RemoveRelationEvent(event_idx);
                        m_relation_events.Remove(event_idx);
                        return;
                    }

                    //是否已经存在相同关系:是则返回;非相同关系先移除,再添加
                    RelationInfo relation_info;
                    if (m_relations.TryGetValue(target_char_idx, out relation_info))
                    {
                        if (relation_info.flags == flag)
                        {
                            SQLRelationHandle.RemoveRelationEvent(event_idx);
                            m_relation_events.Remove(event_idx);
                            return;
                        }
                        else
                        {
                            this.RemoveRelation(target_char_idx);
                        }
                    }

                    //如果对方在线,则取对方身上的数据;否则取数据库的数据
                    Unit target_player = UnitManager.Instance.GetUnitByIdx(target_char_idx);
                    if (target_player != null)
                    {
                        relation_info = CommonObjectPools.Spawn <RelationInfo>();
                        relation_info.Copy(target_player.player_data);
                        relation_info.flags = flag;
                        this.AddRelation(relation_info);
                        this.SyncRelation2SS(target_char_idx);
                    }
                    else
                    {
                        PlayerInfoForGL data = CommonObjectPools.Spawn <PlayerInfoForGL>();
                        SQLCharHandle.QueryCharacterInfo(target_char_idx, data, (ret) =>
                            {
                                if (ret && m_char_idx > 0)
                                {
                                    relation_info = CommonObjectPools.Spawn <RelationInfo>();
                                    relation_info.Copy(data);
                                    relation_info.flags = flag;
                                    this.AddRelation(relation_info);
                                    this.SyncRelation2SS(target_char_idx);
                                }
                                CommonObjectPools.Despawn(data);
                            });
                    }
                }
                else
                {
                    //undo
                }
                //写入事件
                RelationEventInfo e_info = new RelationEventInfo();
                e_info.target_char_idx = target_char_idx;
                e_info.source_char_idx = m_char_idx;
                e_info.event_type      = eRelationEvent.Agree;
                e_info.bin_content.bin_agree_content.flag = flag;
                e_info.bin_content.bin_agree_content.cmd  = cmd;
                SQLRelationHandle.InsertRelationEvent(e_info);
                //立刻通知接受者
                this.BroadcastEvent(e_info.target_char_idx, e_info.event_type);
            }
            break;
            }

            //清除处理过的事件
            SQLRelationHandle.RemoveRelationEvent(event_idx);

            //从事件列表移除
            m_relation_events.Remove(event_idx);
        }
Пример #19
0
        /// <summary>
        /// 处理关系事件
        /// </summary>
        private void HandleRelationEvent(List <RelationEventInfo> list_event)
        {
            //查询过程中如果下线
            if (m_char_idx == 0)
            {
                return;
            }

            Unit player = UnitManager.Instance.GetUnitByIdx(m_char_idx);

            if (player == null)
            {
                return;
            }

            foreach (var relation_evt in list_event)
            {
                switch (relation_evt.event_type)
                {
                case eRelationEvent.Add:    //对方申请加你好友
                {
                    //超过上限
                    if (IsRelationFull(relation_evt.bin_content.bin_add_content.flag))
                    {
                        //清除处理过的事件
                        SQLRelationHandle.RemoveRelationEvent(relation_evt.event_idx);
                        continue;
                    }

                    //是否已经存在相同关系
                    RelationInfo relation_info = null;
                    if (m_relations.TryGetValue(relation_evt.source_char_idx, out relation_info) && relation_info.flags == relation_evt.bin_content.bin_add_content.flag)
                    {
                        //清除处理过的事件
                        SQLRelationHandle.RemoveRelationEvent(relation_evt.event_idx);
                        continue;
                    }

                    //拉黑不需要同意,所以不添加事件
                    if (relation_evt.bin_content.bin_add_content.flag == eRelationFlag.Block)
                    {
                        if (m_relations.TryGetValue(relation_evt.source_char_idx, out relation_info))
                        {        //已经存在其他关系,则用新关系覆盖旧关系
                            relation_info.flags = eRelationFlag.Block;
                            this.SyncRelation2SS(relation_evt.source_char_idx);
                        }
                        else
                        {
                            Unit target_player = UnitManager.Instance.GetUnitByIdx(relation_evt.source_char_idx);
                            if (target_player == null)
                            {
                                PlayerInfoForGL data = CommonObjectPools.Spawn <PlayerInfoForGL>();
                                SQLCharHandle.QueryCharacterInfo(relation_evt.source_char_idx, data, (ret) =>
                                    {
                                        if (ret && m_char_idx > 0)
                                        {
                                            relation_info = CommonObjectPools.Spawn <RelationInfo>();
                                            relation_info.Copy(data);
                                            relation_info.flags = eRelationFlag.Block;
                                            this.AddRelation(relation_info);
                                            this.SyncRelation2SS(relation_evt.source_char_idx);
                                        }
                                        CommonObjectPools.Despawn(data);
                                    });
                            }
                            else
                            {
                                relation_info = CommonObjectPools.Spawn <RelationInfo>();
                                relation_info.Copy(target_player.player_data);
                                relation_info.flags = eRelationFlag.Block;
                                this.AddRelation(relation_info);
                                this.SyncRelation2SS(relation_evt.source_char_idx);
                            }
                        }

                        //清除处理过的事件
                        SQLRelationHandle.RemoveRelationEvent(relation_evt.event_idx);
                        m_relation_events.Remove(relation_evt.event_idx);
                    }
                    else
                    {
                        //添加关系事件
                        if (m_relation_events.ContainsKey(relation_evt.event_idx))
                        {
                            continue;
                        }
                        else
                        {
                            m_relation_events.Add(relation_evt.event_idx, relation_evt);
                        }

                        //通知逻辑服,由逻辑服转发给客户端
                        gl2ss.RelationAdd msg = PacketPools.Get(gl2ss.msg.RELATION_ADD) as gl2ss.RelationAdd;
                        msg.event_idx = relation_evt.event_idx;
                        msg.char_idx  = m_char_idx;
                        msg.player_id.Set(relation_evt.source_char_idx, relation_evt.bin_content.bin_add_content.char_name);
                        msg.message = relation_evt.bin_content.bin_add_content.message;
                        msg.flag    = relation_evt.bin_content.bin_add_content.flag;
                        ForServerNetManager.Instance.Send(player.ss_srv_uid, msg);
                    }
                    break;
                }

                case eRelationEvent.Delete:    //对方删除了你
                {
                    if (m_relations.ContainsKey(relation_evt.source_char_idx))
                    {
                        this.RemoveRelation(relation_evt.source_char_idx);

                        //通知逻辑服,由逻辑服转发给客户端
                        gl2ss.RelationRemove msg_remove = PacketPools.Get(gl2ss.msg.RELATION_REMOVE) as gl2ss.RelationRemove;
                        msg_remove.char_idx   = m_char_idx;
                        msg_remove.target_idx = relation_evt.source_char_idx;
                        ForServerNetManager.Instance.Send(player.ss_srv_uid, msg_remove);
                    }

                    //清除处理过的事件
                    SQLRelationHandle.RemoveRelationEvent(relation_evt.event_idx);
                    m_relation_events.Remove(relation_evt.event_idx);
                    break;
                }

                case eRelationEvent.Agree:    //对方同意了你的申请
                {
                    if (relation_evt.bin_content.bin_agree_content.cmd == eRelationApplyCmd.Agree)
                    {
                        //如果对方在线,则取对方身上的数据;否则取数据库的数据
                        Unit target_player = UnitManager.Instance.GetUnitByIdx(relation_evt.source_char_idx);
                        if (target_player != null)
                        {
                            this.RemoveRelation(relation_evt.source_char_idx);

                            RelationInfo relation_info = CommonObjectPools.Spawn <RelationInfo>();
                            relation_info.Copy(target_player.player_data);
                            relation_info.flags = relation_evt.bin_content.bin_agree_content.flag;
                            this.AddRelation(relation_info);
                            this.SyncRelation2SS(relation_evt.source_char_idx);

                            //清除处理过的事件
                            SQLRelationHandle.RemoveRelationEvent(relation_evt.event_idx);
                            m_relation_events.Remove(relation_evt.event_idx);
                        }
                        else
                        {
                            PlayerInfoForGL data = CommonObjectPools.Spawn <PlayerInfoForGL>();
                            SQLCharHandle.QueryCharacterInfo(relation_evt.source_char_idx, data, (ret) =>
                                {
                                    if (ret && m_char_idx > 0)
                                    {
                                        this.RemoveRelation(relation_evt.source_char_idx);

                                        RelationInfo relation_info = CommonObjectPools.Spawn <RelationInfo>();
                                        relation_info.Copy(data);
                                        relation_info.flags = relation_evt.bin_content.bin_agree_content.flag;
                                        this.AddRelation(relation_info);
                                        this.SyncRelation2SS(relation_evt.source_char_idx);
                                    }
                                    CommonObjectPools.Despawn(data);

                                    //清除处理过的事件
                                    SQLRelationHandle.RemoveRelationEvent(relation_evt.event_idx);
                                    m_relation_events.Remove(relation_evt.event_idx);
                                });
                        }
                    }
                    else
                    {
                        //清除处理过的事件
                        SQLRelationHandle.RemoveRelationEvent(relation_evt.event_idx);
                        m_relation_events.Remove(relation_evt.event_idx);
                    }

                    break;
                }

                case eRelationEvent.Give:
                {
                    Log.Info("赠送 src:" + relation_evt.source_char_idx + " dst:" + relation_evt.target_char_idx);
                    RelationEventContent.GiveContent give_info = relation_evt.bin_content.bin_give_content;
                    //发给ss处理
                    if (item.IsValidItem(give_info.item_id))
                    {
                        gl2ss.RelationGive msg_give = PacketPools.Get(gl2ss.msg.RELATION_GIVE) as gl2ss.RelationGive;
                        msg_give.char_idx = m_char_idx;
                        msg_give.src_player_id.Set(relation_evt.source_char_idx, give_info.char_name);
                        msg_give.item_id = give_info.item_id;
                        ForServerNetManager.Instance.Send(player.ss_srv_uid, msg_give);
                    }

                    //清除处理过的事件
                    SQLRelationHandle.RemoveRelationEvent(relation_evt.event_idx);
                    m_relation_events.Remove(relation_evt.event_idx);
                    break;
                }
                }
            }
        }