예제 #1
0
        public static void Handle(Packet p, Presence pr, OyasumiDbContext context)
        {
            var ms = new MemoryStream(p.Data);

            using var reader = new SerializationReader(ms);

            var id = reader.ReadInt32();

            var friend = PresenceManager.GetPresenceById(id);

            if (friend is null)
            {
                return;
            }

            var exists = context.Friends.FirstOrDefault(x => x.Friend2 == id);

            if (exists is not null)
            {
                return;
            }

            context.Friends.Add(new ()
            {
                Friend1 = pr.Id,
                Friend2 = id
            });

            Base.FriendCache[pr.Id].Add(friend.Id);

            context.SaveChanges();
        }
예제 #2
0
        public static void Handle(Packet p, Presence pr, OyasumiDbContext context)
        {
            var ms = new MemoryStream(p.Data);

            using var reader = new SerializationReader(ms);

            var id = reader.ReadInt32();

            var friend = context.Friends.FirstOrDefault(x => x.Friend2 == id);

            if (friend is null)
            {
                return;
            }

            context.Friends.Remove(friend);

            Base.FriendCache.FirstOrDefault(x => x.Key == friend.Friend1).Value.Remove(friend.Friend2);

            context.SaveChanges();
        }