mirror of https://github.com/ppy/osu
Add password to room settings and multiplayer lounge interface
This commit is contained in:
parent
6a74fde082
commit
2ca11d458a
|
@ -15,6 +15,16 @@ public interface IMultiplayerLoungeServer
|
|||
/// </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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -212,6 +212,8 @@ public Task ChangeSettings(Optional<string> name = default, Optional<PlaylistIte
|
|||
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,
|
||||
|
|
|
@ -36,12 +36,16 @@ public class MultiplayerRoomSettings : IEquatable<MultiplayerRoomSettings>
|
|||
[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 @@ public override string ToString() => $"Name:{Name}"
|
|||
+ $" Beatmap:{BeatmapID} ({BeatmapChecksum})"
|
||||
+ $" RequiredMods:{string.Join(',', RequiredMods)}"
|
||||
+ $" AllowedMods:{string.Join(',', AllowedMods)}"
|
||||
+ $" Password:{(string.IsNullOrEmpty(Password) ? "no" : "yes")}"
|
||||
+ $" Ruleset:{RulesetID}"
|
||||
+ $" Item:{PlaylistItemId}";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue