From 51b2b7dee2367a14441459098fbcfa02c60a67ec Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Tue, 16 Apr 2019 14:26:42 +0100 Subject: [PATCH] Moved Name, SteamId to SteamClient --- Facepunch.Steamworks.Test/GameServerTest.cs | 2 +- Facepunch.Steamworks.Test/UserTest.cs | 12 ++++---- Facepunch.Steamworks/SteamClient.cs | 31 +++++++++++++++++++++ Facepunch.Steamworks/SteamFriends.cs | 11 -------- Facepunch.Steamworks/SteamUser.cs | 18 ------------ 5 files changed, 38 insertions(+), 36 deletions(-) diff --git a/Facepunch.Steamworks.Test/GameServerTest.cs b/Facepunch.Steamworks.Test/GameServerTest.cs index 8175676..6900469 100644 --- a/Facepunch.Steamworks.Test/GameServerTest.cs +++ b/Facepunch.Steamworks.Test/GameServerTest.cs @@ -53,7 +53,7 @@ namespace Steamworks // The client sends this data to the server along with their steamid // var ticketData = clientTicket.Data; - var clientSteamId = SteamUser.SteamId; + var clientSteamId = SteamClient.SteamId; // // Server listens to auth responses from Gabe diff --git a/Facepunch.Steamworks.Test/UserTest.cs b/Facepunch.Steamworks.Test/UserTest.cs index 584953e..106c061 100644 --- a/Facepunch.Steamworks.Test/UserTest.cs +++ b/Facepunch.Steamworks.Test/UserTest.cs @@ -46,15 +46,15 @@ namespace Steamworks [TestMethod] public void IsLoggedOn() { - Assert.AreNotEqual( false, SteamUser.IsLoggedOn ); - Console.WriteLine( $"User.IsLoggedOn: {SteamUser.IsLoggedOn}" ); + Assert.AreNotEqual( false, SteamClient.IsLoggedOn ); + Console.WriteLine( $"User.IsLoggedOn: {SteamClient.IsLoggedOn}" ); } [TestMethod] public void SteamID() { - Assert.AreNotEqual( 0, SteamUser.SteamId.Value ); - Console.WriteLine( $"User.SteamID: {SteamUser.SteamId.Value}" ); + Assert.AreNotEqual( 0, SteamClient.SteamId.Value ); + Console.WriteLine( $"User.SteamID: {SteamClient.SteamId.Value}" ); } [TestMethod] @@ -67,11 +67,11 @@ namespace Steamworks Console.WriteLine( $"ticket.Handle: {ticket.Handle}" ); Console.WriteLine( $"ticket.Data: { string.Join( "", ticket.Data.Select( x => x.ToString( "x" ) ) ) }" ); - var result = SteamUser.BeginAuthSession( ticket.Data, SteamUser.SteamId ); + var result = SteamUser.BeginAuthSession( ticket.Data, SteamClient.SteamId ); Console.WriteLine( $"result: { result }" ); Assert.AreEqual( result, BeginAuthResult.OK ); - SteamUser.EndAuthSession( SteamUser.SteamId ); + SteamUser.EndAuthSession( SteamClient.SteamId ); } diff --git a/Facepunch.Steamworks/SteamClient.cs b/Facepunch.Steamworks/SteamClient.cs index d81963b..a8a96d8 100644 --- a/Facepunch.Steamworks/SteamClient.cs +++ b/Facepunch.Steamworks/SteamClient.cs @@ -75,5 +75,36 @@ namespace Steamworks { SteamApi.UnregisterCallback( intPtr ); } + + /// + /// Checks if the current user's Steam client is connected to the Steam servers. + /// If it's not then no real-time services provided by the Steamworks API will be enabled. The Steam + /// client will automatically be trying to recreate the connection as often as possible. When the + /// connection is restored a SteamServersConnected_t callback will be posted. + /// You usually don't need to check for this yourself. All of the API calls that rely on this will + /// check internally. Forcefully disabling stuff when the player loses access is usually not a + /// very good experience for the player and you could be preventing them from accessing APIs that do not + /// need a live connection to Steam. + /// + public static bool IsLoggedOn => SteamUser.Internal.BLoggedOn(); + + /// + /// Gets the Steam ID of the account currently logged into the Steam client. This is + /// commonly called the 'current user', or 'local user'. + /// A Steam ID is a unique identifier for a Steam accounts, Steam groups, Lobbies and Chat + /// rooms, and used to differentiate users in all parts of the Steamworks API. + /// + public static SteamId SteamId => SteamUser.Internal.GetSteamID(); + + /// + /// returns the local players name - guaranteed to not be NULL. + /// this is the same name as on the users community profile page + /// + public static string Name => SteamFriends.Internal.GetPersonaName(); + + /// + /// gets the status of the current user + /// + public static FriendState State => SteamFriends.Internal.GetPersonaState(); } } \ No newline at end of file diff --git a/Facepunch.Steamworks/SteamFriends.cs b/Facepunch.Steamworks/SteamFriends.cs index f059cac..150c9df 100644 --- a/Facepunch.Steamworks/SteamFriends.cs +++ b/Facepunch.Steamworks/SteamFriends.cs @@ -104,17 +104,6 @@ namespace Steamworks } } - /// - /// returns the local players name - guaranteed to not be NULL. - /// this is the same name as on the users community profile page - /// - public static string Name => Internal.GetPersonaName(); - - /// - /// gets the status of the current user - /// - public static FriendState State => Internal.GetPersonaState(); - public static IEnumerable GetFriends() { for ( int i=0; i public static event Action OnGameWebCallback; - /// - /// Checks if the current user's Steam client is connected to the Steam servers. - /// If it's not then no real-time services provided by the Steamworks API will be enabled. The Steam - /// client will automatically be trying to recreate the connection as often as possible. When the - /// connection is restored a SteamServersConnected_t callback will be posted. - /// You usually don't need to check for this yourself. All of the API calls that rely on this will - /// check internally. Forcefully disabling stuff when the player loses access is usually not a - /// very good experience for the player and you could be preventing them from accessing APIs that do not - /// need a live connection to Steam. - /// - public static bool IsLoggedOn => Internal.BLoggedOn(); - /// - /// Gets the Steam ID of the account currently logged into the Steam client. This is - /// commonly called the 'current user', or 'local user'. - /// A Steam ID is a unique identifier for a Steam accounts, Steam groups, Lobbies and Chat - /// rooms, and used to differentiate users in all parts of the Steamworks API. - /// - public static SteamId SteamId => Internal.GetSteamID(); static bool _recordingVoice;