mirror of
https://github.com/ppy/osu.git
synced 2025-03-23 02:57:25 +08:00
Fire-and-forget leave-room request
This commit is contained in:
parent
b002c46666
commit
f876a329b1
@ -77,7 +77,9 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
||||
/// <param name="room">The API <see cref="Room"/>.</param>
|
||||
public async Task JoinRoom(Room room)
|
||||
{
|
||||
Debug.Assert(Room == null);
|
||||
if (Room != null)
|
||||
throw new InvalidOperationException("Cannot join a multiplayer room while already in one.");
|
||||
|
||||
Debug.Assert(room.RoomID.Value != null);
|
||||
|
||||
apiRoom = room;
|
||||
@ -166,6 +168,9 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
||||
|
||||
Task IMultiplayerClient.RoomStateChanged(MultiplayerRoomState state)
|
||||
{
|
||||
if (Room == null)
|
||||
return Task.CompletedTask;
|
||||
|
||||
Schedule(() =>
|
||||
{
|
||||
if (Room == null)
|
||||
@ -198,6 +203,9 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
||||
|
||||
async Task IMultiplayerClient.UserJoined(MultiplayerRoomUser user)
|
||||
{
|
||||
if (Room == null)
|
||||
return;
|
||||
|
||||
await PopulateUser(user);
|
||||
|
||||
Schedule(() =>
|
||||
@ -213,6 +221,9 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
||||
|
||||
Task IMultiplayerClient.UserLeft(MultiplayerRoomUser user)
|
||||
{
|
||||
if (Room == null)
|
||||
return Task.CompletedTask;
|
||||
|
||||
Schedule(() =>
|
||||
{
|
||||
if (Room == null)
|
||||
@ -229,6 +240,9 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
||||
|
||||
Task IMultiplayerClient.HostChanged(int userId)
|
||||
{
|
||||
if (Room == null)
|
||||
return Task.CompletedTask;
|
||||
|
||||
Schedule(() =>
|
||||
{
|
||||
if (Room == null)
|
||||
@ -255,6 +269,9 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
||||
|
||||
Task IMultiplayerClient.UserStateChanged(int userId, MultiplayerUserState state)
|
||||
{
|
||||
if (Room == null)
|
||||
return Task.CompletedTask;
|
||||
|
||||
Schedule(() =>
|
||||
{
|
||||
if (Room == null)
|
||||
@ -273,6 +290,9 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
||||
|
||||
Task IMultiplayerClient.LoadRequested()
|
||||
{
|
||||
if (Room == null)
|
||||
return Task.CompletedTask;
|
||||
|
||||
Schedule(() =>
|
||||
{
|
||||
if (Room == null)
|
||||
@ -286,7 +306,9 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
||||
|
||||
Task IMultiplayerClient.MatchStarted()
|
||||
{
|
||||
Debug.Assert(Room != null);
|
||||
if (Room == null)
|
||||
return Task.CompletedTask;
|
||||
|
||||
var players = Room.Users.Where(u => u.State == MultiplayerUserState.Playing).Select(u => u.UserID).ToList();
|
||||
|
||||
Schedule(() =>
|
||||
@ -304,6 +326,9 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
||||
|
||||
Task IMultiplayerClient.ResultsReady()
|
||||
{
|
||||
if (Room == null)
|
||||
return Task.CompletedTask;
|
||||
|
||||
Schedule(() =>
|
||||
{
|
||||
if (Room == null)
|
||||
|
@ -49,7 +49,7 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
||||
var joinedRoom = JoinedRoom;
|
||||
|
||||
base.PartRoom();
|
||||
multiplayerClient.LeaveRoom().Wait();
|
||||
multiplayerClient.LeaveRoom();
|
||||
|
||||
// Todo: This is not the way to do this. Basically when we're the only participant and the room closes, there's no way to know if this is actually the case.
|
||||
RemoveRoom(joinedRoom);
|
||||
|
Loading…
x
Reference in New Issue
Block a user