mirror of
https://github.com/ppy/osu
synced 2025-02-09 14:47:33 +00:00
Merge branch 'socket-client' into websocket-chat-2
This commit is contained in:
commit
3816152c9d
@ -7,7 +7,7 @@ using Microsoft.AspNetCore.SignalR.Client;
|
||||
|
||||
namespace osu.Game.Online
|
||||
{
|
||||
public class HubClient : SocketClient
|
||||
public class HubClient : PersistentEndpointClient
|
||||
{
|
||||
public readonly HubConnection Connection;
|
||||
|
||||
|
@ -14,7 +14,7 @@ using osu.Game.Online.API;
|
||||
|
||||
namespace osu.Game.Online
|
||||
{
|
||||
public class HubClientConnector : SocketClientConnector, IHubClientConnector
|
||||
public class HubClientConnector : PersistentEndpointClientConnector, IHubClientConnector
|
||||
{
|
||||
public const string SERVER_SHUTDOWN_MESSAGE = "Server is shutting down.";
|
||||
|
||||
@ -51,7 +51,7 @@ namespace osu.Game.Online
|
||||
this.preferMessagePack = preferMessagePack;
|
||||
}
|
||||
|
||||
protected override Task<SocketClient> BuildConnectionAsync(CancellationToken cancellationToken)
|
||||
protected override Task<PersistentEndpointClient> BuildConnectionAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var builder = new HubConnectionBuilder()
|
||||
.WithUrl(endpoint, options =>
|
||||
@ -91,7 +91,7 @@ namespace osu.Game.Online
|
||||
|
||||
ConfigureConnection?.Invoke(newConnection);
|
||||
|
||||
return Task.FromResult((SocketClient)new HubClient(newConnection));
|
||||
return Task.FromResult((PersistentEndpointClient)new HubClient(newConnection));
|
||||
}
|
||||
|
||||
protected override string ClientName { get; }
|
||||
|
@ -15,7 +15,7 @@ namespace osu.Game.Online.Notifications
|
||||
/// <summary>
|
||||
/// An abstract client which receives notification-related events (chat/notifications).
|
||||
/// </summary>
|
||||
public abstract class NotificationsClient : SocketClient
|
||||
public abstract class NotificationsClient : PersistentEndpointClient
|
||||
{
|
||||
public Action<Channel>? ChannelJoined;
|
||||
public Action<List<Message>>? NewMessages;
|
||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Online.Notifications
|
||||
/// <summary>
|
||||
/// An abstract connector or <see cref="NotificationsClient"/>s.
|
||||
/// </summary>
|
||||
public abstract class NotificationsClientConnector : SocketClientConnector
|
||||
public abstract class NotificationsClientConnector : PersistentEndpointClientConnector
|
||||
{
|
||||
public event Action<Channel>? ChannelJoined;
|
||||
public event Action<List<Message>>? NewMessages;
|
||||
@ -34,7 +34,7 @@ namespace osu.Game.Online.Notifications
|
||||
client.EnableChat = true;
|
||||
}
|
||||
|
||||
protected sealed override async Task<SocketClient> BuildConnectionAsync(CancellationToken cancellationToken)
|
||||
protected sealed override async Task<PersistentEndpointClient> BuildConnectionAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var client = await BuildNotificationClientAsync(cancellationToken);
|
||||
|
||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace osu.Game.Online
|
||||
{
|
||||
public abstract class SocketClient : IAsyncDisposable
|
||||
public abstract class PersistentEndpointClient : IAsyncDisposable
|
||||
{
|
||||
public event Func<Exception?, Task>? Closed;
|
||||
|
@ -11,7 +11,7 @@ using osu.Game.Online.API;
|
||||
|
||||
namespace osu.Game.Online
|
||||
{
|
||||
public abstract class SocketClientConnector : IDisposable
|
||||
public abstract class PersistentEndpointClientConnector : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether this is connected to the hub, use <see cref="CurrentConnection"/> to access the connection, if this is <c>true</c>.
|
||||
@ -21,7 +21,7 @@ namespace osu.Game.Online
|
||||
/// <summary>
|
||||
/// The current connection opened by this connector.
|
||||
/// </summary>
|
||||
public SocketClient? CurrentConnection { get; private set; }
|
||||
public PersistentEndpointClient? CurrentConnection { get; private set; }
|
||||
|
||||
protected readonly IAPIProvider API;
|
||||
|
||||
@ -34,7 +34,7 @@ namespace osu.Game.Online
|
||||
/// Constructs a new <see cref="HubClientConnector"/>.
|
||||
/// </summary>
|
||||
/// <param name="api"> An API provider used to react to connection state changes.</param>
|
||||
protected SocketClientConnector(IAPIProvider api)
|
||||
protected PersistentEndpointClientConnector(IAPIProvider api)
|
||||
{
|
||||
API = api;
|
||||
|
||||
@ -126,7 +126,7 @@ namespace osu.Game.Online
|
||||
await Task.Delay(5000, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
protected abstract Task<SocketClient> BuildConnectionAsync(CancellationToken cancellationToken);
|
||||
protected abstract Task<PersistentEndpointClient> BuildConnectionAsync(CancellationToken cancellationToken);
|
||||
|
||||
private async Task onConnectionClosed(Exception? ex, CancellationToken cancellationToken)
|
||||
{
|
Loading…
Reference in New Issue
Block a user