Added Friends.OnInvitedToGame callback

This commit is contained in:
Garry Newman 2018-02-15 12:43:52 +00:00
parent 2587643b25
commit dd31847990

View File

@ -40,6 +40,23 @@ internal Friends( Client c )
client = c;
client.RegisterCallback<SteamNative.PersonaStateChange_t>( OnPersonaStateChange );
client.RegisterCallback<SteamNative.GameRichPresenceJoinRequested_t>( OnGameJoinRequested );
}
public delegate void JoinRequestedDelegate( SteamFriend friend, string connect );
//
// Called when a friend has invited you to their game (using InviteToGame)
//
public event JoinRequestedDelegate OnInvitedToGame;
private void OnGameJoinRequested( GameRichPresenceJoinRequested_t data )
{
if ( OnInvitedToGame != null )
{
OnInvitedToGame( Get( data.SteamIDFriend ), data.Connect );
}
}
/// <summary>
@ -226,6 +243,9 @@ private class PersonaCallback
public SteamFriend Get( ulong steamid )
{
var friend = All.Where( x => x.Id == steamid ).FirstOrDefault();
if ( friend != null ) return friend;
var f = new SteamFriend()
{
Id = steamid,