From 072ef291a0cee86dc193b548904882d0db1eb49d Mon Sep 17 00:00:00 2001 From: Alexander Storozhuk Date: Sat, 14 Apr 2018 13:42:15 +0300 Subject: [PATCH] Added documentation for rich presence. Changed SetRichPresence return type to bool. Updated rich presence test. --- .../Client/RichPresenceTest.cs | 6 ++++-- Facepunch.Steamworks/Client/User.cs | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Facepunch.Steamworks.Test/Client/RichPresenceTest.cs b/Facepunch.Steamworks.Test/Client/RichPresenceTest.cs index b261979..ad64ae2 100644 --- a/Facepunch.Steamworks.Test/Client/RichPresenceTest.cs +++ b/Facepunch.Steamworks.Test/Client/RichPresenceTest.cs @@ -26,7 +26,8 @@ public void ReadBackSetKey() { using ( var client = new Steamworks.Client( 252490 ) ) { - client.User.SetRichPresence( "One", "Two" ); + var success = client.User.SetRichPresence( "One", "Two" ); + Assert.IsTrue( success ); var value = client.User.GetRichPresence( "One" ); Assert.IsNotNull( value ); @@ -39,7 +40,8 @@ public void ClearingKeys() { using ( var client = new Steamworks.Client( 252490 ) ) { - client.User.SetRichPresence( "One", "Two" ); + var success = client.User.SetRichPresence( "One", "Two" ); + Assert.IsTrue( success ); var value = client.User.GetRichPresence( "One" ); Assert.IsNotNull( value ); diff --git a/Facepunch.Steamworks/Client/User.cs b/Facepunch.Steamworks/Client/User.cs index daf3363..75f8ffe 100644 --- a/Facepunch.Steamworks/Client/User.cs +++ b/Facepunch.Steamworks/Client/User.cs @@ -25,22 +25,29 @@ public void Dispose() client = null; } + /// + /// Find a rich presence data by key for current user. Will be null if not found. + /// public string GetRichPresence( string key ) { - string val = null; - - if ( richPresence.TryGetValue( key, out val ) ) + if ( richPresence.TryGetValue( key, out var val ) ) return val; return null; } - public void SetRichPresence( string key, string value ) + /// + /// Sets rich presence value by key for current user. + /// + public bool SetRichPresence( string key, string value ) { richPresence[key] = value; - client.native.friends.SetRichPresence( key, value ); + return client.native.friends.SetRichPresence( key, value ); } + /// + /// Clears all of the current user's rich presence data. + /// public void ClearRichPresence() { richPresence.Clear();