mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:12:54 +08:00
Use IDisposable instead
This commit is contained in:
parent
c9108ce41b
commit
e59c8b7d24
@ -6,13 +6,12 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.TypeExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Online.API;
|
||||
|
||||
namespace osu.Game.Online
|
||||
{
|
||||
public abstract class PersistentEndpointClientConnector : Component
|
||||
public abstract class PersistentEndpointClientConnector : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether this is connected to the hub, use <see cref="CurrentConnection"/> to access the connection, if this is <c>true</c>.
|
||||
@ -173,11 +172,23 @@ namespace osu.Game.Online
|
||||
|
||||
public override string ToString() => $"{ClientName} ({(IsConnected.Value ? "connected" : "not connected")})";
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
private bool isDisposed;
|
||||
|
||||
protected virtual void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
if (isDisposed)
|
||||
return;
|
||||
|
||||
apiState.UnbindAll();
|
||||
cancelExistingConnect();
|
||||
|
||||
isDisposed = true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user