2020-12-18 16:17:24 +00: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.
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2021-11-23 07:04:11 +00:00
|
|
|
using System;
|
2020-12-18 16:17:24 +00:00
|
|
|
using System.Collections.Generic;
|
2021-11-26 08:23:50 +00:00
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2020-12-25 04:38:11 +00:00
|
|
|
using osu.Game.Online.Rooms;
|
2021-06-25 09:02:53 +00:00
|
|
|
using osu.Game.Screens.OnlinePlay.Components;
|
2020-12-25 15:50:00 +00:00
|
|
|
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
2021-08-19 03:24:06 +00:00
|
|
|
using osu.Game.Tests.Visual.OnlinePlay;
|
2020-12-18 16:17:24 +00:00
|
|
|
|
2020-12-25 04:38:11 +00:00
|
|
|
namespace osu.Game.Tests.Visual.Multiplayer
|
2020-12-18 16:17:24 +00:00
|
|
|
{
|
2021-06-25 09:02:53 +00:00
|
|
|
/// <summary>
|
2021-10-27 07:10:22 +00:00
|
|
|
/// A <see cref="RoomManager"/> for use in multiplayer test scenes.
|
2021-08-19 03:24:06 +00:00
|
|
|
/// Should generally not be used by itself outside of a <see cref="MultiplayerTestScene"/>.
|
2021-06-25 09:02:53 +00:00
|
|
|
/// </summary>
|
2022-11-24 05:32:20 +00:00
|
|
|
public partial class TestMultiplayerRoomManager : MultiplayerRoomManager
|
2020-12-18 16:17:24 +00:00
|
|
|
{
|
2021-10-28 05:29:49 +00:00
|
|
|
private readonly TestRoomRequestsHandler requestsHandler;
|
|
|
|
|
|
|
|
public TestMultiplayerRoomManager(TestRoomRequestsHandler requestsHandler)
|
|
|
|
{
|
|
|
|
this.requestsHandler = requestsHandler;
|
|
|
|
}
|
2020-12-18 16:17:24 +00:00
|
|
|
|
2021-10-27 07:10:22 +00:00
|
|
|
public IReadOnlyList<Room> ServerSideRooms => requestsHandler.ServerSideRooms;
|
2020-12-18 16:17:24 +00:00
|
|
|
|
2021-11-23 07:04:11 +00:00
|
|
|
public override void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
|
2021-12-20 04:10:13 +00:00
|
|
|
=> base.CreateRoom(room, r => onSuccess?.Invoke(r), onError);
|
2021-11-23 07:04:11 +00:00
|
|
|
|
|
|
|
public override void JoinRoom(Room room, string password = null, Action<Room> onSuccess = null, Action<string> onError = null)
|
2021-12-20 04:10:13 +00:00
|
|
|
=> base.JoinRoom(room, password, r => onSuccess?.Invoke(r), onError);
|
2021-11-23 07:04:11 +00:00
|
|
|
|
2021-08-19 03:24:06 +00: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>
|
2021-11-26 08:23:50 +00:00
|
|
|
/// <param name="host">The host.</param>
|
|
|
|
public void AddServerSideRoom(Room room, APIUser host) => requestsHandler.AddServerSideRoom(room, host);
|
2020-12-18 16:17:24 +00:00
|
|
|
}
|
|
|
|
}
|