diff --git a/Facepunch.Steamworks/Client.cs b/Facepunch.Steamworks/Client.cs index 61ec9d5..d5694ef 100644 --- a/Facepunch.Steamworks/Client.cs +++ b/Facepunch.Steamworks/Client.cs @@ -6,6 +6,11 @@ namespace Facepunch.Steamworks { public partial class Client : BaseSteamworks { + /// + /// A singleton accessor to get the current client instance. + /// + public static Client Instance { get; private set; } + /// /// Current user's Username /// @@ -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(); } diff --git a/Facepunch.Steamworks/Server.cs b/Facepunch.Steamworks/Server.cs index 0b3011c..715a2b2 100644 --- a/Facepunch.Steamworks/Server.cs +++ b/Facepunch.Steamworks/Server.cs @@ -13,6 +13,11 @@ namespace Facepunch.Steamworks /// public partial class Server : BaseSteamworks { + /// + /// A singleton accessor to get the current client instance. + /// + 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 /// A string defining version, ie "1001" 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(); }