2020-12-19 01:30:53 +08:00
|
|
|
// 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 JetBrains.Annotations;
|
|
|
|
using osu.Framework.Allocation;
|
2020-12-25 12:38:11 +08:00
|
|
|
using osu.Game.Online.Multiplayer;
|
2020-12-19 01:30:53 +08:00
|
|
|
|
2020-12-25 23:50:00 +08:00
|
|
|
namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
2020-12-19 01:30:53 +08:00
|
|
|
{
|
2020-12-26 00:12:33 +08:00
|
|
|
public abstract class MultiplayerRoomComposite : OnlinePlayComposite
|
2020-12-19 01:30:53 +08:00
|
|
|
{
|
|
|
|
[CanBeNull]
|
|
|
|
protected MultiplayerRoom Room => Client.Room;
|
|
|
|
|
|
|
|
[Resolved]
|
2021-05-20 14:39:45 +08:00
|
|
|
protected MultiplayerClient Client { get; private set; }
|
2020-12-19 01:30:53 +08:00
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2020-12-26 09:48:55 +08:00
|
|
|
Client.RoomUpdated += OnRoomUpdated;
|
2021-08-25 13:25:57 +08:00
|
|
|
|
|
|
|
Client.UserLeft += UserLeft;
|
|
|
|
Client.UserKicked += UserKicked;
|
|
|
|
Client.UserJoined += UserJoined;
|
|
|
|
|
2020-12-26 09:48:55 +08:00
|
|
|
OnRoomUpdated();
|
2020-12-19 01:30:53 +08:00
|
|
|
}
|
|
|
|
|
2021-08-25 13:25:57 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Invoked when a user has joined the room.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="user">The user.</param>
|
|
|
|
protected virtual void UserJoined(MultiplayerRoomUser user)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Invoked when a user has been kicked from the room (including the local user).
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="user">The user.</param>
|
|
|
|
protected virtual void UserKicked(MultiplayerRoomUser user)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Invoked when a user has left the room.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="user">The user.</param>
|
|
|
|
protected virtual void UserLeft(MultiplayerRoomUser user)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-12-26 09:48:55 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Invoked when any change occurs to the multiplayer room.
|
|
|
|
/// </summary>
|
|
|
|
protected virtual void OnRoomUpdated()
|
2020-12-19 01:30:53 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
{
|
|
|
|
if (Client != null)
|
2021-08-25 13:25:57 +08:00
|
|
|
{
|
|
|
|
Client.UserLeft -= UserLeft;
|
|
|
|
Client.UserKicked -= UserKicked;
|
|
|
|
Client.UserJoined -= UserJoined;
|
2020-12-26 09:48:55 +08:00
|
|
|
Client.RoomUpdated -= OnRoomUpdated;
|
2021-08-25 13:25:57 +08:00
|
|
|
}
|
2020-12-19 01:30:53 +08:00
|
|
|
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|