예제 #1
0
        /// <summary>
        /// 添加关系
        /// </summary>
        private void OnRelationAdd(PacketBase packet)
        {
            c2ss.RelationAdd msg = packet as c2ss.RelationAdd;

            //判断数据有效性
            if ((msg.target_id.type == eRelationAddType.Idx && msg.target_id.char_idx <= 0) ||
                (msg.target_id.type == eRelationAddType.Name && string.IsNullOrEmpty(msg.target_id.char_name)))
            {
                return;
            }

            Player player = UnitManager.Instance.GetPlayerByClientUID(msg.client_uid);

            if (player == null)
            {
                Log.Debug("OnRelationAdd 未找到unit:" + msg.client_uid.srv_uid + ", " + msg.client_uid.conn_idx);
                return;
            }

            //不能加自己
            if ((msg.target_id.type == eRelationAddType.Idx && msg.target_id.char_idx == player.char_idx) ||
                (msg.target_id.type == eRelationAddType.Name && msg.target_id.char_name == player.char_name))
            {
                return;
            }

            MemberRelation relation = RelationManager.Instance.GetMember(player.char_idx);

            if (relation != null)
            {
                relation.AddRelationClient(msg.target_id, msg.flag, msg.message);
            }
        }
예제 #2
0
 /// <summary>
 /// 请求添加好友
 /// </summary>
 public static void SendRelationAdd(RelationAddTarget target, eRelationFlag flag, string message)
 {
     c2ss.RelationAdd msg = PacketPools.Get(c2ss.msg.RELATION_ADD) as c2ss.RelationAdd;
     msg.target_id = target;
     msg.message   = message;
     msg.flag      = flag;
     ClientNetManager.Instance.Send(msg);
 }