mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Add remaining pieces of password flow (for osu-web join request)
This commit is contained in:
@ -152,7 +152,7 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
onSuccess?.Invoke(room);
|
onSuccess?.Invoke(room);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void JoinRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null) => throw new NotImplementedException();
|
public void JoinRoom(Room room, string password, Action<Room> onSuccess = null, Action<string> onError = null) => throw new NotImplementedException();
|
||||||
|
|
||||||
public void PartRoom() => throw new NotImplementedException();
|
public void PartRoom() => throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,8 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
/// Joins the <see cref="MultiplayerRoom"/> for a given API <see cref="Room"/>.
|
/// Joins the <see cref="MultiplayerRoom"/> for a given API <see cref="Room"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="room">The API <see cref="Room"/>.</param>
|
/// <param name="room">The API <see cref="Room"/>.</param>
|
||||||
public async Task JoinRoom(Room room)
|
/// <param name="password">An optional password to use for the join operation.</param>
|
||||||
|
public async Task JoinRoom(Room room, string? password = null)
|
||||||
{
|
{
|
||||||
var cancellationSource = joinCancellationSource = new CancellationTokenSource();
|
var cancellationSource = joinCancellationSource = new CancellationTokenSource();
|
||||||
|
|
||||||
@ -127,7 +128,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
Debug.Assert(room.RoomID.Value != null);
|
Debug.Assert(room.RoomID.Value != null);
|
||||||
|
|
||||||
// Join the server-side room.
|
// Join the server-side room.
|
||||||
var joinedRoom = await JoinRoom(room.RoomID.Value.Value, room.Password.Value).ConfigureAwait(false);
|
var joinedRoom = await JoinRoom(room.RoomID.Value.Value, password ?? room.Password.Value).ConfigureAwait(false);
|
||||||
Debug.Assert(joinedRoom != null);
|
Debug.Assert(joinedRoom != null);
|
||||||
|
|
||||||
// Populate users.
|
// Populate users.
|
||||||
|
@ -23,6 +23,6 @@ namespace osu.Game.Online.Rooms
|
|||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string Target => $"rooms/{room.RoomID.Value}/users/{User.Id}";
|
protected override string Target => $"rooms/{room.RoomID.Value}/users/{User.Id}?password={room.Password.Value}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,8 +84,11 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
|||||||
|
|
||||||
private JoinRoomRequest currentJoinRoomRequest;
|
private JoinRoomRequest currentJoinRoomRequest;
|
||||||
|
|
||||||
public virtual void JoinRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
|
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?.Cancel();
|
||||||
currentJoinRoomRequest = new JoinRoomRequest(room);
|
currentJoinRoomRequest = new JoinRoomRequest(room);
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
namespace osu.Game.Screens.OnlinePlay
|
namespace osu.Game.Screens.OnlinePlay
|
||||||
{
|
{
|
||||||
[Cached(typeof(IRoomManager))]
|
[Cached(typeof(IRoomManager))]
|
||||||
@ -32,15 +34,16 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
/// <param name="room">The <see cref="Room"/> to create.</param>
|
/// <param name="room">The <see cref="Room"/> to create.</param>
|
||||||
/// <param name="onSuccess">An action to be invoked if the creation succeeds.</param>
|
/// <param name="onSuccess">An action to be invoked if the creation succeeds.</param>
|
||||||
/// <param name="onError">An action to be invoked if an error occurred.</param>
|
/// <param name="onError">An action to be invoked if an error occurred.</param>
|
||||||
void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null);
|
void CreateRoom(Room room, Action<Room>? onSuccess = null, Action<string>? onError = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Joins a <see cref="Room"/>.
|
/// Joins a <see cref="Room"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="room">The <see cref="Room"/> to join. <see cref="Room.RoomID"/> must be populated.</param>
|
/// <param name="room">The <see cref="Room"/> to join. <see cref="Room.RoomID"/> must be populated.</param>
|
||||||
|
/// <param name="password">An optional password to use for the join operation.</param>
|
||||||
/// <param name="onSuccess"></param>
|
/// <param name="onSuccess"></param>
|
||||||
/// <param name="onError"></param>
|
/// <param name="onError"></param>
|
||||||
void JoinRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null);
|
void JoinRoom(Room room, string? password = null, Action<Room>? onSuccess = null, Action<string>? onError = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parts the currently-joined <see cref="Room"/>.
|
/// Parts the currently-joined <see cref="Room"/>.
|
||||||
|
@ -167,14 +167,14 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
|||||||
filter.HoldFocus = false;
|
filter.HoldFocus = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void joinRequested(Room room)
|
public void Join(Room room, string password)
|
||||||
{
|
{
|
||||||
if (joiningRoomOperation != null)
|
if (joiningRoomOperation != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
joiningRoomOperation = ongoingOperationTracker?.BeginOperation();
|
joiningRoomOperation = ongoingOperationTracker?.BeginOperation();
|
||||||
|
|
||||||
RoomManager?.JoinRoom(room, r =>
|
RoomManager?.JoinRoom(room, password, r =>
|
||||||
{
|
{
|
||||||
Open(room);
|
Open(room);
|
||||||
joiningRoomOperation?.Dispose();
|
joiningRoomOperation?.Dispose();
|
||||||
|
@ -38,9 +38,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
|
public override void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
|
||||||
=> base.CreateRoom(room, r => joinMultiplayerRoom(r, onSuccess, onError), onError);
|
=> base.CreateRoom(room, r => joinMultiplayerRoom(r, r.Password.Value, onSuccess, onError), onError);
|
||||||
|
|
||||||
public override void JoinRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
|
public override void JoinRoom(Room room, string password = null, Action<Room> onSuccess = null, Action<string> onError = null)
|
||||||
{
|
{
|
||||||
if (!multiplayerClient.IsConnected.Value)
|
if (!multiplayerClient.IsConnected.Value)
|
||||||
{
|
{
|
||||||
@ -56,7 +56,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
base.JoinRoom(room, r => joinMultiplayerRoom(r, onSuccess, onError), onError);
|
base.JoinRoom(room, password, r => joinMultiplayerRoom(r, password, onSuccess, onError), onError);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void PartRoom()
|
public override void PartRoom()
|
||||||
@ -79,11 +79,11 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void joinMultiplayerRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
|
private void joinMultiplayerRoom(Room room, string password, Action<Room> onSuccess = null, Action<string> onError = null)
|
||||||
{
|
{
|
||||||
Debug.Assert(room.RoomID.Value != null);
|
Debug.Assert(room.RoomID.Value != null);
|
||||||
|
|
||||||
multiplayerClient.JoinRoom(room).ContinueWith(t =>
|
multiplayerClient.JoinRoom(room, password).ContinueWith(t =>
|
||||||
{
|
{
|
||||||
if (t.IsCompletedSuccessfully)
|
if (t.IsCompletedSuccessfully)
|
||||||
Schedule(() => onSuccess?.Invoke(room));
|
Schedule(() => onSuccess?.Invoke(room));
|
||||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Tests.Visual.OnlinePlay
|
|||||||
onSuccess?.Invoke(room);
|
onSuccess?.Invoke(room);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void JoinRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null) => onSuccess?.Invoke(room);
|
public void JoinRoom(Room room, string password, Action<Room> onSuccess = null, Action<string> onError = null) => onSuccess?.Invoke(room);
|
||||||
|
|
||||||
public void PartRoom()
|
public void PartRoom()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user