// 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.Threading; using System.Threading.Tasks; namespace osu.Game.Online { public abstract class PersistentEndpointClient : IAsyncDisposable { /// /// An event notifying the that the connection has been closed /// public event Func? Closed; /// /// Notifies the that the connection has been closed. /// /// The exception that the connection closed with. protected Task InvokeClosed(Exception? exception) => Closed?.Invoke(exception) ?? Task.CompletedTask; /// /// Connects the client to the remote service to begin processing messages. /// /// A cancellation token to stop processing messages. public abstract Task ConnectAsync(CancellationToken cancellationToken); public virtual ValueTask DisposeAsync() { Closed = null; return new ValueTask(Task.CompletedTask); } } }