1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 08:32:57 +08:00

xmldoc everything

This commit is contained in:
Bartłomiej Dach 2024-01-25 14:46:39 +01:00
parent de52f0a80c
commit c463aa5ba1
No known key found for this signature in database
6 changed files with 50 additions and 13 deletions

View File

@ -130,8 +130,14 @@ namespace osu.Game.Online.API
/// <param name="preferMessagePack">Whether to use MessagePack for serialisation if available on this platform.</param>
IHubClientConnector? GetHubConnector(string clientName, string endpoint, bool preferMessagePack = true);
/// <summary>
/// Accesses the <see cref="INotificationsClient"/> used to receive asynchronous notifications from web.
/// </summary>
INotificationsClient NotificationsClient { get; }
/// <summary>
/// Creates a <see cref="IChatClient"/> instance to use in order to chat.
/// </summary>
IChatClient GetChatClient();
/// <summary>

View File

@ -91,7 +91,7 @@ namespace osu.Game.Online.Chat
chatClient.ChannelParted += ch => Schedule(() => leaveChannel(getChannel(ch), false));
chatClient.NewMessages += msgs => Schedule(() => addMessages(msgs));
chatClient.PresenceReceived += () => Schedule(initializeChannels);
chatClient.FetchInitialMessages();
chatClient.RequestPresence();
apiState.BindTo(api.State);
apiState.BindValueChanged(_ => SendAck(), true);

View File

@ -6,13 +6,34 @@ using System.Collections.Generic;
namespace osu.Game.Online.Chat
{
/// <summary>
/// Interface for consuming online chat.
/// </summary>
public interface IChatClient : IDisposable
{
/// <summary>
/// Fired when a <see cref="Channel"/> has been joined.
/// </summary>
event Action<Channel>? ChannelJoined;
event Action<Channel>? ChannelParted;
event Action<List<Message>>? NewMessages;
event Action? PresenceReceived;
void FetchInitialMessages();
/// <summary>
/// Fired when a <see cref="Channel"/> has been parted.
/// </summary>
event Action<Channel>? ChannelParted;
/// <summary>
/// Fired when new <see cref="Message"/>s have arrived from the server.
/// </summary>
event Action<List<Message>>? NewMessages;
/// <summary>
/// Requests presence information from the server.
/// </summary>
void RequestPresence();
/// <summary>
/// Fired when the initial user presence information has been received.
/// </summary>
event Action? PresenceReceived;
}
}

View File

@ -40,14 +40,10 @@ namespace osu.Game.Online.Chat
client.MessageReceived += onMessageReceived;
client.SendAsync(new StartChatRequest()).WaitSafely();
RequestPresence();
}
public void FetchInitialMessages()
{
api.Queue(createInitialFetchRequest());
}
private APIRequest createInitialFetchRequest()
public void RequestPresence()
{
var fetchReq = new GetUpdatesRequest(0);
@ -64,7 +60,7 @@ namespace osu.Game.Online.Chat
PresenceReceived?.Invoke();
};
return fetchReq;
api.Queue(fetchReq);
}
private void onMessageReceived(SocketMessage message)

View File

@ -8,10 +8,24 @@ using osu.Framework.Bindables;
namespace osu.Game.Online.Notifications.WebSocket
{
/// <summary>
/// A client for asynchronous notifications sent by osu-web.
/// </summary>
public interface INotificationsClient
{
/// <summary>
/// Whether this <see cref="INotificationsClient"/> is currently connected to a server.
/// </summary>
IBindable<bool> IsConnected { get; }
/// <summary>
/// Invoked when a new <see cref="SocketMessage"/> arrives for this client.
/// </summary>
event Action<SocketMessage>? MessageReceived;
/// <summary>
/// Sends a <see cref="SocketMessage"/> to the notification server.
/// </summary>
Task SendAsync(SocketMessage message, CancellationToken? cancellationToken = default);
}
}

View File

@ -24,7 +24,7 @@ namespace osu.Game.Tests
public event Action<List<Message>>? NewMessages;
public event Action? PresenceReceived;
public void FetchInitialMessages()
public void RequestPresence()
{
// don't really need to do anything special if we poll every second anyway.
}