mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-25 06:05:46 +03:00
Singleton accessors for Client/Server
This commit is contained in:
parent
d417f22336
commit
67fd7fe00a
@ -6,6 +6,11 @@ namespace Facepunch.Steamworks
|
||||
{
|
||||
public partial class Client : BaseSteamworks
|
||||
{
|
||||
/// <summary>
|
||||
/// A singleton accessor to get the current client instance.
|
||||
/// </summary>
|
||||
public static Client Instance { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Current user's Username
|
||||
/// </summary>
|
||||
@ -56,6 +61,7 @@ public partial class Client : BaseSteamworks
|
||||
|
||||
public Client( uint appId )
|
||||
{
|
||||
Instance = this;
|
||||
native = new Interop.NativeInterface();
|
||||
|
||||
//
|
||||
@ -162,6 +168,11 @@ public override void Dispose()
|
||||
Achievements = null;
|
||||
}
|
||||
|
||||
if ( Instance == this )
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,11 @@ namespace Facepunch.Steamworks
|
||||
/// </summary>
|
||||
public partial class Server : BaseSteamworks
|
||||
{
|
||||
/// <summary>
|
||||
/// A singleton accessor to get the current client instance.
|
||||
/// </summary>
|
||||
public static Server Instance { get; private set; }
|
||||
|
||||
internal override bool IsGameServer { get { return true; } }
|
||||
|
||||
public ServerQuery Query { get; internal set; }
|
||||
@ -31,6 +36,7 @@ public partial class Server : BaseSteamworks
|
||||
/// <param name="VersionString">A string defining version, ie "1001"</param>
|
||||
public Server( uint appId, uint IpAddress, ushort SteamPort, ushort GamePort, ushort QueryPort, bool Secure, string VersionString )
|
||||
{
|
||||
Instance = this;
|
||||
native = new Interop.NativeInterface();
|
||||
|
||||
//
|
||||
@ -284,6 +290,11 @@ public override void Dispose()
|
||||
Auth = null;
|
||||
}
|
||||
|
||||
if ( Instance == this )
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user