mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 15:03:13 +08:00
Send password in request ctor directly
This commit is contained in:
parent
35b5f0462c
commit
125bd36ab1
@ -10,19 +10,22 @@ namespace osu.Game.Online.Rooms
|
||||
public class JoinRoomRequest : APIRequest
|
||||
{
|
||||
private readonly Room room;
|
||||
private readonly string password;
|
||||
|
||||
public JoinRoomRequest(Room room)
|
||||
public JoinRoomRequest(Room room, string password)
|
||||
{
|
||||
this.room = room;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
protected override WebRequest CreateWebRequest()
|
||||
{
|
||||
var req = base.CreateWebRequest();
|
||||
req.Method = HttpMethod.Put;
|
||||
req.AddParameter("password", password);
|
||||
return req;
|
||||
}
|
||||
|
||||
protected override string Target => $"rooms/{room.RoomID.Value}/users/{User.Id}?password={room.Password.Value}";
|
||||
protected override string Target => $"rooms/{room.RoomID.Value}/users/{User.Id}";
|
||||
}
|
||||
}
|
||||
|
@ -86,11 +86,8 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
|
||||
public virtual void JoinRoom(Room room, string password = null, Action<Room> onSuccess = null, Action<string> onError = null)
|
||||
{
|
||||
// todo: send into JoinRoomRequest directly?
|
||||
room.Password.Value = password;
|
||||
|
||||
currentJoinRoomRequest?.Cancel();
|
||||
currentJoinRoomRequest = new JoinRoomRequest(room);
|
||||
currentJoinRoomRequest = new JoinRoomRequest(room, password);
|
||||
|
||||
currentJoinRoomRequest.Success += () =>
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user