Merge pull request #151 from alevastor/master

Improvements for rich presence
This commit is contained in:
Garry Newman 2018-07-24 10:13:38 +01:00 committed by GitHub
commit 24df7fb6ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 value 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 a 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();