2019-01-24 08:43:03 +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.
|
2018-12-22 03:50:37 +00:00
|
|
|
|
|
|
|
using System.Collections.Generic;
|
2020-07-10 10:54:09 +00:00
|
|
|
using Humanizer;
|
2020-07-10 08:26:42 +00:00
|
|
|
using osu.Framework.IO.Network;
|
2020-07-22 09:29:50 +00:00
|
|
|
using osu.Game.Online.API;
|
2018-12-22 03:50:37 +00:00
|
|
|
using osu.Game.Screens.Multi.Lounge.Components;
|
|
|
|
|
2020-07-22 09:29:50 +00:00
|
|
|
namespace osu.Game.Online.Multiplayer
|
2018-12-22 03:50:37 +00:00
|
|
|
{
|
|
|
|
public class GetRoomsRequest : APIRequest<List<Room>>
|
|
|
|
{
|
2020-07-10 08:26:42 +00:00
|
|
|
private readonly RoomStatusFilter statusFilter;
|
|
|
|
private readonly RoomCategoryFilter categoryFilter;
|
2018-12-22 03:50:37 +00:00
|
|
|
|
2020-07-10 08:26:42 +00:00
|
|
|
public GetRoomsRequest(RoomStatusFilter statusFilter, RoomCategoryFilter categoryFilter)
|
2018-12-22 03:50:37 +00:00
|
|
|
{
|
2020-07-10 08:26:42 +00:00
|
|
|
this.statusFilter = statusFilter;
|
|
|
|
this.categoryFilter = categoryFilter;
|
2018-12-22 03:50:37 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 08:26:42 +00:00
|
|
|
protected override WebRequest CreateWebRequest()
|
2018-12-22 03:50:37 +00:00
|
|
|
{
|
2020-07-10 08:26:42 +00:00
|
|
|
var req = base.CreateWebRequest();
|
2019-04-01 03:44:46 +00:00
|
|
|
|
2020-07-10 10:54:09 +00:00
|
|
|
if (statusFilter != RoomStatusFilter.Open)
|
|
|
|
req.AddParameter("mode", statusFilter.ToString().Underscore().ToLowerInvariant());
|
|
|
|
|
|
|
|
if (categoryFilter != RoomCategoryFilter.Any)
|
|
|
|
req.AddParameter("category", categoryFilter.ToString().Underscore().ToLowerInvariant());
|
2020-07-10 08:26:42 +00:00
|
|
|
|
|
|
|
return req;
|
2018-12-22 03:50:37 +00:00
|
|
|
}
|
2020-07-10 08:26:42 +00:00
|
|
|
|
|
|
|
protected override string Target => "rooms";
|
2018-12-22 03:50:37 +00:00
|
|
|
}
|
|
|
|
}
|