示例#1
0
        /// <summary>请求取得好友名单
        ///     <remark>abu 2008-03-11 </remark>
        /// </summary>
        /// <param name="position">The position.</param>
        private void GetFriendList(int startPosition)
        {
            GetFriendListPacket packet = new GetFriendListPacket(QQUser);

            packet.StartPosition = (ushort)startPosition;
            QQClient.PacketManager.SendPacket(packet, QQPort.Main.Name);
        }
示例#2
0
        public void FriendsListRequestHandler(GetFriendListPacket packet, IRakConnection connection)
        {
            var session = Server.SessionCache.GetSession(connection.EndPoint);
            var zone    = ((WorldServer)Server).Zones.FirstOrDefault(z => (int)z.ZoneId == session.ZoneId);

            if (zone == default)
            {
                Logger.Error($"Invalid ZoneId for {connection}");
                return;
            }

            using var ctx = new UchuContext();
            var character = ctx.Characters.First(c => c.CharacterId == session.CharacterId);

            var relations = ctx.Friends.Where(f =>
                                              f.FriendId == character.CharacterId || f.FriendTwoId == character.CharacterId
                                              ).ToArray();

            var friends = new List <FriendListPacket.Friend>();

            foreach (var characterFriend in relations)
            {
                if (!characterFriend.IsAccepted)
                {
                    continue;
                }

                var friendId = characterFriend.FriendTwoId == character.CharacterId
                    ? characterFriend.FriendId
                    : characterFriend.FriendTwoId;

                var friend = ctx.Characters.First(c => c.CharacterId == friendId);

                var player = zone.Players.FirstOrDefault(p => p.ObjectId == friend.CharacterId);
                friends.Add(new FriendListPacket.Friend
                {
                    IsBestFriend  = characterFriend.IsBestFriend,
                    IsFreeToPlay  = friend.FreeToPlay,
                    IsOnline      = player != default,
                    PlayerId      = player?.ObjectId ?? -1,
                    PlayerName    = friend.Name,
                    ZoneId        = (ZoneId)friend.LastZone,
                    WorldClone    = (uint)friend.LastClone,
                    WorldInstance = (ushort)friend.LastInstance
                });
示例#3
0
        public async Task FriendsListRequestHandler(GetFriendListPacket packet, IRakConnection connection)
        {
            var session = UchuServer.SessionCache.GetSession(connection.EndPoint);
            var zone    = ((WorldUchuServer)UchuServer).Zones.FirstOrDefault(z => (int)z.ZoneId == session.ZoneId);

            if (zone == default)
            {
                Logger.Error($"Invalid ZoneId for {connection}");
                return;
            }

            await using var ctx = new UchuContext();
            var character = await ctx.Characters.FirstAsync(c => c.Id == session.CharacterId);

            var relations = await ctx.Friends.Where(f =>
                                                    f.FriendA == character.Id || f.FriendB == character.Id
                                                    ).ToArrayAsync();

            var friends = new List <FriendListPacket.Friend>();

            foreach (var characterFriend in relations)
            {
                var friendId = characterFriend.FriendA == character.Id
                    ? characterFriend.FriendB
                    : characterFriend.FriendA;

                var friend = ctx.Characters.First(c => c.Id == friendId);

                var player = zone.Players.FirstOrDefault(p => p.Id == friend.Id);

                friends.Add(new FriendListPacket.Friend
                {
                    IsBestFriend  = characterFriend.BestFriend,
                    IsFreeToPlay  = friend.FreeToPlay,
                    IsOnline      = player != default,
                    PlayerId      = player?.Id ?? -1,
                    PlayerName    = friend.Name,
                    ZoneId        = (ZoneId)friend.LastZone,
                    WorldClone    = (uint)friend.LastClone,
                    WorldInstance = (ushort)friend.LastInstance
                });
示例#4
0
 /// <summary>
 /// 处理得到好友列表应答
 ///     <remark>abu 2008-03-11 </remark>
 /// </summary>
 /// <param name="packet">The packet.</param>
 private void ProcessGetFriendListReply(GetFriendListReplyPacket inPacket, GetFriendListPacket outPacket)
 {
     client.FriendManager.OnGetFriendListSuccessed(new QQEventArgs <GetFriendListReplyPacket, GetFriendListPacket>(client, inPacket, outPacket));
 }