mirror of
https://github.com/ppy/osu.git
synced 2025-03-12 00:37:19 +08:00
Rename methods
This commit is contained in:
parent
9a623257f5
commit
7c38089c75
@ -171,7 +171,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
throw new InvalidOperationException("Cannot join a multiplayer room while already in one.");
|
throw new InvalidOperationException("Cannot join a multiplayer room while already in one.");
|
||||||
|
|
||||||
var cancellationSource = joinCancellationSource = new CancellationTokenSource();
|
var cancellationSource = joinCancellationSource = new CancellationTokenSource();
|
||||||
await initRoom(room, r => CreateRoom(new MultiplayerRoom(room)), cancellationSource.Token).ConfigureAwait(false);
|
await initRoom(room, r => CreateRoomInternal(new MultiplayerRoom(room)), cancellationSource.Token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -187,7 +187,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
Debug.Assert(room.RoomID != null);
|
Debug.Assert(room.RoomID != null);
|
||||||
|
|
||||||
var cancellationSource = joinCancellationSource = new CancellationTokenSource();
|
var cancellationSource = joinCancellationSource = new CancellationTokenSource();
|
||||||
await initRoom(room, r => JoinRoom(room.RoomID.Value, password ?? room.Password), cancellationSource.Token).ConfigureAwait(false);
|
await initRoom(room, r => JoinRoomInternal(room.RoomID.Value, password ?? room.Password), cancellationSource.Token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task initRoom(Room room, Func<Room, Task<MultiplayerRoom>> initFunc, CancellationToken cancellationToken)
|
private async Task initRoom(Room room, Func<Room, Task<MultiplayerRoom>> initFunc, CancellationToken cancellationToken)
|
||||||
@ -236,21 +236,6 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates the <see cref="MultiplayerRoom"/> with the given settings.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="room">The room.</param>
|
|
||||||
/// <returns>The joined <see cref="MultiplayerRoom"/></returns>
|
|
||||||
protected abstract Task<MultiplayerRoom> CreateRoom(MultiplayerRoom room);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Joins the <see cref="MultiplayerRoom"/> with a given ID.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="roomId">The room ID.</param>
|
|
||||||
/// <param name="password">An optional password to use when joining the room.</param>
|
|
||||||
/// <returns>The joined <see cref="MultiplayerRoom"/>.</returns>
|
|
||||||
protected abstract Task<MultiplayerRoom> JoinRoom(long roomId, string? password = null);
|
|
||||||
|
|
||||||
public Task LeaveRoom()
|
public Task LeaveRoom()
|
||||||
{
|
{
|
||||||
if (Room == null)
|
if (Room == null)
|
||||||
@ -279,6 +264,24 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the <see cref="MultiplayerRoom"/> with the given settings.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="room">The room.</param>
|
||||||
|
/// <returns>The joined <see cref="MultiplayerRoom"/></returns>
|
||||||
|
protected abstract Task<MultiplayerRoom> CreateRoomInternal(MultiplayerRoom room);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Joins the <see cref="MultiplayerRoom"/> with a given ID.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="roomId">The room ID.</param>
|
||||||
|
/// <param name="password">An optional password to use when joining the room.</param>
|
||||||
|
/// <returns>The joined <see cref="MultiplayerRoom"/>.</returns>
|
||||||
|
protected abstract Task<MultiplayerRoom> JoinRoomInternal(long roomId, string? password = null);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Leaves the currently-joined <see cref="MultiplayerRoom"/>.
|
||||||
|
/// </summary>
|
||||||
protected abstract Task LeaveRoomInternal();
|
protected abstract Task LeaveRoomInternal();
|
||||||
|
|
||||||
public abstract Task InvitePlayer(int userId);
|
public abstract Task InvitePlayer(int userId);
|
||||||
|
@ -75,7 +75,32 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task<MultiplayerRoom> JoinRoom(long roomId, string? password = null)
|
protected override async Task<MultiplayerRoom> CreateRoomInternal(MultiplayerRoom room)
|
||||||
|
{
|
||||||
|
if (!IsConnected.Value)
|
||||||
|
throw new OperationCanceledException();
|
||||||
|
|
||||||
|
Debug.Assert(connection != null);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return await connection.InvokeAsync<MultiplayerRoom>(nameof(IMultiplayerServer.CreateRoom), room).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch (HubException exception)
|
||||||
|
{
|
||||||
|
if (exception.GetHubExceptionMessage() == HubClientConnector.SERVER_SHUTDOWN_MESSAGE)
|
||||||
|
{
|
||||||
|
Debug.Assert(connector != null);
|
||||||
|
|
||||||
|
await connector.Reconnect().ConfigureAwait(false);
|
||||||
|
return await CreateRoomInternal(room).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task<MultiplayerRoom> JoinRoomInternal(long roomId, string? password = null)
|
||||||
{
|
{
|
||||||
if (!IsConnected.Value)
|
if (!IsConnected.Value)
|
||||||
throw new OperationCanceledException();
|
throw new OperationCanceledException();
|
||||||
@ -93,7 +118,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
Debug.Assert(connector != null);
|
Debug.Assert(connector != null);
|
||||||
|
|
||||||
await connector.Reconnect().ConfigureAwait(false);
|
await connector.Reconnect().ConfigureAwait(false);
|
||||||
return await JoinRoom(roomId, password).ConfigureAwait(false);
|
return await JoinRoomInternal(roomId, password).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
@ -266,31 +291,6 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
return connection.InvokeAsync(nameof(IMultiplayerServer.RemovePlaylistItem), playlistItemId);
|
return connection.InvokeAsync(nameof(IMultiplayerServer.RemovePlaylistItem), playlistItemId);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task<MultiplayerRoom> CreateRoom(MultiplayerRoom room)
|
|
||||||
{
|
|
||||||
if (!IsConnected.Value)
|
|
||||||
throw new OperationCanceledException();
|
|
||||||
|
|
||||||
Debug.Assert(connection != null);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return await connection.InvokeAsync<MultiplayerRoom>(nameof(IMultiplayerServer.CreateRoom), room).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
catch (HubException exception)
|
|
||||||
{
|
|
||||||
if (exception.GetHubExceptionMessage() == HubClientConnector.SERVER_SHUTDOWN_MESSAGE)
|
|
||||||
{
|
|
||||||
Debug.Assert(connector != null);
|
|
||||||
|
|
||||||
await connector.Reconnect().ConfigureAwait(false);
|
|
||||||
return await CreateRoom(room).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Task DisconnectInternal()
|
public override Task DisconnectInternal()
|
||||||
{
|
{
|
||||||
if (connector == null)
|
if (connector == null)
|
||||||
|
@ -208,7 +208,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
((IMultiplayerClient)this).UserBeatmapAvailabilityChanged(clone(userId), clone(user.BeatmapAvailability));
|
((IMultiplayerClient)this).UserBeatmapAvailabilityChanged(clone(userId), clone(user.BeatmapAvailability));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task<MultiplayerRoom> JoinRoom(long roomId, string? password = null)
|
protected override async Task<MultiplayerRoom> JoinRoomInternal(long roomId, string? password = null)
|
||||||
{
|
{
|
||||||
if (RoomJoined || ServerAPIRoom != null)
|
if (RoomJoined || ServerAPIRoom != null)
|
||||||
throw new InvalidOperationException("Already joined a room");
|
throw new InvalidOperationException("Already joined a room");
|
||||||
@ -485,7 +485,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
public override Task RemovePlaylistItem(long playlistItemId) => RemoveUserPlaylistItem(api.LocalUser.Value.OnlineID, clone(playlistItemId));
|
public override Task RemovePlaylistItem(long playlistItemId) => RemoveUserPlaylistItem(api.LocalUser.Value.OnlineID, clone(playlistItemId));
|
||||||
|
|
||||||
protected override Task<MultiplayerRoom> CreateRoom(MultiplayerRoom room)
|
protected override Task<MultiplayerRoom> CreateRoomInternal(MultiplayerRoom room)
|
||||||
{
|
{
|
||||||
Room apiRoom = new Room(room)
|
Room apiRoom = new Room(room)
|
||||||
{
|
{
|
||||||
@ -495,7 +495,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
};
|
};
|
||||||
|
|
||||||
AddServerSideRoom(apiRoom, api.LocalUser.Value);
|
AddServerSideRoom(apiRoom, api.LocalUser.Value);
|
||||||
return JoinRoom(apiRoom.RoomID!.Value, room.Settings.Password);
|
return JoinRoomInternal(apiRoom.RoomID!.Value, room.Settings.Password);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task changeMatchType(MatchType type)
|
private async Task changeMatchType(MatchType type)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user