2020-12-19 00:17:24 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Game.Online.API;
|
2020-12-25 12:38:11 +08:00
|
|
|
using osu.Game.Online.Rooms;
|
2021-06-25 17:02:53 +08:00
|
|
|
using osu.Game.Screens.OnlinePlay.Components;
|
2020-12-25 23:50:00 +08:00
|
|
|
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
2021-08-19 11:24:06 +08:00
|
|
|
using osu.Game.Tests.Visual.OnlinePlay;
|
2020-12-19 00:17:24 +08:00
|
|
|
|
2020-12-25 12:38:11 +08:00
|
|
|
namespace osu.Game.Tests.Visual.Multiplayer
|
2020-12-19 00:17:24 +08:00
|
|
|
{
|
2021-06-25 17:02:53 +08:00
|
|
|
/// <summary>
|
2021-08-19 11:24:06 +08:00
|
|
|
/// A <see cref="RoomManager"/> for use in multiplayer test scenes, backed by a <see cref="TestRoomRequestsHandler"/>.
|
|
|
|
/// Should generally not be used by itself outside of a <see cref="MultiplayerTestScene"/>.
|
2021-06-25 17:02:53 +08:00
|
|
|
/// </summary>
|
2021-07-26 14:47:13 +08:00
|
|
|
public class TestRequestHandlingMultiplayerRoomManager : MultiplayerRoomManager
|
2020-12-19 00:17:24 +08:00
|
|
|
{
|
2021-08-19 11:24:06 +08:00
|
|
|
public IReadOnlyList<Room> ServerSideRooms => handler.ServerSideRooms;
|
2020-12-19 00:17:24 +08:00
|
|
|
|
2021-08-19 11:24:06 +08:00
|
|
|
private readonly TestRoomRequestsHandler handler = new TestRoomRequestsHandler();
|
2021-07-26 14:47:13 +08:00
|
|
|
|
2021-06-25 14:00:10 +08:00
|
|
|
[BackgroundDependencyLoader]
|
2021-08-19 11:24:06 +08:00
|
|
|
private void load(IAPIProvider api, OsuGameBase game)
|
2020-12-19 00:17:24 +08:00
|
|
|
{
|
2021-08-19 11:24:06 +08:00
|
|
|
((DummyAPIAccess)api).HandleRequest = request => handler.HandleRequest(request, api.LocalUser.Value, game);
|
2020-12-19 00:17:24 +08:00
|
|
|
}
|
|
|
|
|
2021-08-19 11:24:06 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Adds a room to a local "server-side" list that's returned when a <see cref="GetRoomsRequest"/> is fired.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="room">The room.</param>
|
|
|
|
public void AddServerSideRoom(Room room) => handler.AddServerSideRoom(room);
|
2020-12-19 00:17:24 +08:00
|
|
|
}
|
|
|
|
}
|