mirror of
https://github.com/osukey/osukey.git
synced 2025-05-09 15:47:38 +09:00
Move null check in JoinRoom
on to update thread
This commit is contained in:
parent
d50f41225f
commit
64c63fe93a
@ -163,13 +163,13 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
/// <param name="password">An optional password to use for the join operation.</param>
|
/// <param name="password">An optional password to use for the join operation.</param>
|
||||||
public async Task JoinRoom(Room room, string? password = null)
|
public async Task JoinRoom(Room room, string? password = null)
|
||||||
{
|
{
|
||||||
|
if (Room != null)
|
||||||
|
throw new InvalidOperationException("Cannot join a multiplayer room while already in one.");
|
||||||
|
|
||||||
var cancellationSource = joinCancellationSource = new CancellationTokenSource();
|
var cancellationSource = joinCancellationSource = new CancellationTokenSource();
|
||||||
|
|
||||||
await joinOrLeaveTaskChain.Add(async () =>
|
await joinOrLeaveTaskChain.Add(async () =>
|
||||||
{
|
{
|
||||||
if (Room != null)
|
|
||||||
throw new InvalidOperationException("Cannot join a multiplayer room while already in one.");
|
|
||||||
|
|
||||||
Debug.Assert(room.RoomID.Value != null);
|
Debug.Assert(room.RoomID.Value != null);
|
||||||
|
|
||||||
// Join the server-side room.
|
// Join the server-side room.
|
||||||
@ -183,6 +183,8 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
// Update the stored room (must be done on update thread for thread-safety).
|
// Update the stored room (must be done on update thread for thread-safety).
|
||||||
await runOnUpdateThreadAsync(() =>
|
await runOnUpdateThreadAsync(() =>
|
||||||
{
|
{
|
||||||
|
Debug.Assert(Room == null);
|
||||||
|
|
||||||
Room = joinedRoom;
|
Room = joinedRoom;
|
||||||
APIRoom = room;
|
APIRoom = room;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user