Add handling for GetRoomRequest()

This commit is contained in:
smoogipoo 2020-12-19 01:22:52 +09:00
parent c6da680c80
commit 2fc5561b7e
2 changed files with 21 additions and 4 deletions

View File

@ -7,13 +7,13 @@ namespace osu.Game.Online.Multiplayer
{ {
public class GetRoomRequest : APIRequest<Room> public class GetRoomRequest : APIRequest<Room>
{ {
private readonly int roomId; public readonly int RoomId;
public GetRoomRequest(int roomId) public GetRoomRequest(int roomId)
{ {
this.roomId = roomId; RoomId = roomId;
} }
protected override string Target => $"rooms/{roomId}"; protected override string Target => $"rooms/{RoomId}";
} }
} }

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
@ -52,7 +53,23 @@ namespace osu.Game.Tests.Visual.RealtimeMultiplayer
break; break;
case GetRoomsRequest getRoomsRequest: case GetRoomsRequest getRoomsRequest:
getRoomsRequest.TriggerSuccess(rooms); var roomsWithoutParticipants = new List<Room>();
foreach (var r in rooms)
{
var newRoom = new Room();
newRoom.CopyFrom(r);
newRoom.RecentParticipants.Clear();
roomsWithoutParticipants.Add(newRoom);
}
getRoomsRequest.TriggerSuccess(roomsWithoutParticipants);
break;
case GetRoomRequest getRoomRequest:
getRoomRequest.TriggerSuccess(rooms.Single(r => r.RoomID.Value == getRoomRequest.RoomId));
break; break;
case GetBeatmapSetRequest getBeatmapSetRequest: case GetBeatmapSetRequest getBeatmapSetRequest: