Added documentation for rich presence. Changed SetRichPresence return type to bool. Updated rich presence test.

This commit is contained in:
Alexander Storozhuk 2018-04-14 13:42:15 +03:00
parent 46f56c24f3
commit 072ef291a0
2 changed files with 16 additions and 7 deletions

View File

@ -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 );

View File

@ -25,22 +25,29 @@ public void Dispose()
client = null;
}
/// <summary>
/// Find a rich presence data by key for current user. Will be null if not found.
/// </summary>
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 )
/// <summary>
/// Sets rich presence value by key for current user.
/// </summary>
public bool SetRichPresence( string key, string value )
{
richPresence[key] = value;
client.native.friends.SetRichPresence( key, value );
return client.native.friends.SetRichPresence( key, value );
}
/// <summary>
/// Clears all of the current user's rich presence data.
/// </summary>
public void ClearRichPresence()
{
richPresence.Clear();