1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 00:47:24 +08:00

Add password to room settings and multiplayer lounge interface

This commit is contained in:
Dean Herbert 2021-07-09 00:53:10 +09:00
parent 6a74fde082
commit 2ca11d458a
4 changed files with 39 additions and 0 deletions

View File

@ -15,6 +15,16 @@ namespace osu.Game.Online.Multiplayer
/// </summary>
/// <param name="roomId">The databased room ID.</param>
/// <exception cref="InvalidStateException">If the user is already in the requested (or another) room.</exception>
/// <exception cref="InvalidPasswordException">If the room required a password.</exception>
Task<MultiplayerRoom> JoinRoom(long roomId);
/// <summary>
/// Request to join a multiplayer room with a provided password.
/// </summary>
/// <param name="roomId">The databased room ID.</param>
/// <param name="password">The password for the join request.</param>
/// <exception cref="InvalidStateException">If the user is already in the requested (or another) room.</exception>
/// <exception cref="InvalidPasswordException">If the room provided password was incorrect.</exception>
Task<MultiplayerRoom> JoinRoom(long roomId, string password);
}
}

View File

@ -0,0 +1,22 @@
// 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.
using System;
using System.Runtime.Serialization;
using Microsoft.AspNetCore.SignalR;
namespace osu.Game.Online.Multiplayer
{
[Serializable]
public class InvalidPasswordException : HubException
{
public InvalidPasswordException()
{
}
protected InvalidPasswordException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}

View File

@ -212,6 +212,8 @@ namespace osu.Game.Online.Multiplayer
return ChangeSettings(new MultiplayerRoomSettings
{
Name = name.GetOr(Room.Settings.Name),
// TODO: add changing support
Password = Room.Settings.Password,
BeatmapID = item.GetOr(existingPlaylistItem).BeatmapID,
BeatmapChecksum = item.GetOr(existingPlaylistItem).Beatmap.Value.MD5Hash,
RulesetID = item.GetOr(existingPlaylistItem).RulesetID,

View File

@ -36,12 +36,16 @@ namespace osu.Game.Online.Multiplayer
[Key(6)]
public long PlaylistItemId { get; set; }
[Key(7)]
public string Password { get; set; } = string.Empty;
public bool Equals(MultiplayerRoomSettings other)
=> BeatmapID == other.BeatmapID
&& BeatmapChecksum == other.BeatmapChecksum
&& RequiredMods.SequenceEqual(other.RequiredMods)
&& AllowedMods.SequenceEqual(other.AllowedMods)
&& RulesetID == other.RulesetID
&& Password.Equals(other.Password, StringComparison.Ordinal)
&& Name.Equals(other.Name, StringComparison.Ordinal)
&& PlaylistItemId == other.PlaylistItemId;
@ -49,6 +53,7 @@ namespace osu.Game.Online.Multiplayer
+ $" Beatmap:{BeatmapID} ({BeatmapChecksum})"
+ $" RequiredMods:{string.Join(',', RequiredMods)}"
+ $" AllowedMods:{string.Join(',', AllowedMods)}"
+ $" Password:{(string.IsNullOrEmpty(Password) ? "no" : "yes")}"
+ $" Ruleset:{RulesetID}"
+ $" Item:{PlaylistItemId}";
}