Leave the multiplayer channel when leaving multiplayer

This commit is contained in:
Dean Herbert 2021-01-21 15:42:23 +09:00
parent 11a9a4c773
commit e6980688f6
2 changed files with 13 additions and 3 deletions

View File

@ -339,7 +339,7 @@ namespace osu.Game.Online.Chat
}
/// <summary>
/// Joins a channel if it has not already been joined.
/// Joins a channel if it has not already been joined. Must be called from the update thread.
/// </summary>
/// <param name="channel">The channel to join.</param>
/// <returns>The joined channel. Note that this may not match the parameter channel as it is a backed object.</returns>
@ -399,7 +399,11 @@ namespace osu.Game.Online.Chat
return channel;
}
public void LeaveChannel(Channel channel)
/// <summary>
/// Leave the specified channel. Can be called from any thread.
/// </summary>
/// <param name="channel">The channel to leave.</param>
public void LeaveChannel(Channel channel) => Schedule(() =>
{
if (channel == null) return;
@ -413,7 +417,7 @@ namespace osu.Game.Online.Chat
api.Queue(new LeaveChannelRequest(channel));
channel.Joined.Value = false;
}
}
});
private long lastMessageId;

View File

@ -38,5 +38,11 @@ namespace osu.Game.Screens.OnlinePlay.Match.Components
Channel.Value = channelManager?.JoinChannel(new Channel { Id = channelId.Value, Type = ChannelType.Multiplayer, Name = $"#lazermp_{roomId.Value}" });
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
channelManager?.LeaveChannel(Channel.Value);
}
}
}