mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Change API for retrieving playlist items on join
This commit is contained in:
@ -77,6 +77,11 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
/// <exception cref="InvalidStateException">If an attempt to start the game occurs when the game's (or users') state disallows it.</exception>
|
/// <exception cref="InvalidStateException">If an attempt to start the game occurs when the game's (or users') state disallows it.</exception>
|
||||||
Task StartMatch();
|
Task StartMatch();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Requests for all playlist items of the room to be sent to the client.
|
||||||
|
/// </summary>
|
||||||
|
Task RequestAllPlaylistItems();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds an item to the playlist.
|
/// Adds an item to the playlist.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -158,6 +158,8 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
OnRoomJoined();
|
OnRoomJoined();
|
||||||
}, cancellationSource.Token).ConfigureAwait(false);
|
}, cancellationSource.Token).ConfigureAwait(false);
|
||||||
|
|
||||||
|
await RequestAllPlaylistItems().ConfigureAwait(false);
|
||||||
|
|
||||||
// Update room settings.
|
// Update room settings.
|
||||||
await updateLocalRoomSettings(joinedRoom.Settings, cancellationSource.Token).ConfigureAwait(false);
|
await updateLocalRoomSettings(joinedRoom.Settings, cancellationSource.Token).ConfigureAwait(false);
|
||||||
}, cancellationSource.Token).ConfigureAwait(false);
|
}, cancellationSource.Token).ConfigureAwait(false);
|
||||||
@ -305,6 +307,8 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
|
|
||||||
public abstract Task StartMatch();
|
public abstract Task StartMatch();
|
||||||
|
|
||||||
|
public abstract Task RequestAllPlaylistItems();
|
||||||
|
|
||||||
public abstract Task AddPlaylistItem(APIPlaylistItem item);
|
public abstract Task AddPlaylistItem(APIPlaylistItem item);
|
||||||
|
|
||||||
public abstract Task RemovePlaylistItem(long playlistItemId);
|
public abstract Task RemovePlaylistItem(long playlistItemId);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -151,6 +152,14 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
return connection.InvokeAsync(nameof(IMultiplayerServer.StartMatch));
|
return connection.InvokeAsync(nameof(IMultiplayerServer.StartMatch));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override Task RequestAllPlaylistItems()
|
||||||
|
{
|
||||||
|
if (!IsConnected.Value)
|
||||||
|
return Task.FromResult(Array.Empty<APIPlaylistItem>());
|
||||||
|
|
||||||
|
return connection.InvokeAsync<APIPlaylistItem[]>(nameof(IMultiplayerServer.RequestAllPlaylistItems));
|
||||||
|
}
|
||||||
|
|
||||||
public override Task AddPlaylistItem(APIPlaylistItem item)
|
public override Task AddPlaylistItem(APIPlaylistItem item)
|
||||||
{
|
{
|
||||||
if (!IsConnected.Value)
|
if (!IsConnected.Value)
|
||||||
|
@ -199,10 +199,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
// emulate the server sending this after the join room. scheduler required to make sure the join room event is fired first (in Join).
|
// emulate the server sending this after the join room. scheduler required to make sure the join room event is fired first (in Join).
|
||||||
changeMatchType(Room.Settings.MatchType).Wait();
|
changeMatchType(Room.Settings.MatchType).Wait();
|
||||||
|
|
||||||
// emulate the server sending all playlist items after room join.
|
|
||||||
var serverSideRoom = roomManager.ServerSideRooms.Single(r => r.RoomID.Value == APIRoom.RoomID.Value);
|
|
||||||
Task.WhenAll(serverSideRoom.Playlist.Select(i => ((IMultiplayerClient)this).PlaylistItemAdded(new APIPlaylistItem(i)))).Wait();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Task LeaveRoomInternal() => Task.CompletedTask;
|
protected override Task LeaveRoomInternal() => Task.CompletedTask;
|
||||||
@ -298,6 +294,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
return ((IMultiplayerClient)this).LoadRequested();
|
return ((IMultiplayerClient)this).LoadRequested();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override async Task RequestAllPlaylistItems()
|
||||||
|
{
|
||||||
|
foreach (var item in playlistItems)
|
||||||
|
await ((IMultiplayerClient)this).PlaylistItemAdded(item).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
public override async Task AddPlaylistItem(APIPlaylistItem item)
|
public override async Task AddPlaylistItem(APIPlaylistItem item)
|
||||||
{
|
{
|
||||||
Debug.Assert(Room != null);
|
Debug.Assert(Room != null);
|
||||||
|
Reference in New Issue
Block a user