// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using osu.Game.Online.API; using osu.Game.Online.Chat; namespace osu.Game.Online.Notifications { /// /// An abstract connector or s. /// public abstract class NotificationsClientConnector : PersistentEndpointClientConnector { public event Action? ChannelJoined; public event Action? ChannelParted; public event Action>? NewMessages; public event Action? PresenceReceived; protected NotificationsClientConnector(IAPIProvider api) : base(api) { } protected sealed override async Task BuildConnectionAsync(CancellationToken cancellationToken) { var client = await BuildNotificationClientAsync(cancellationToken); client.ChannelJoined = c => ChannelJoined?.Invoke(c); client.ChannelParted = c => ChannelParted?.Invoke(c); client.NewMessages = m => NewMessages?.Invoke(m); client.PresenceReceived = () => PresenceReceived?.Invoke(); return client; } protected abstract Task BuildNotificationClientAsync(CancellationToken cancellationToken); } }