diff --git a/Facepunch.Steamworks/Client/Friends.cs b/Facepunch.Steamworks/Client/Friends.cs index fcfb094..3c557b7 100644 --- a/Facepunch.Steamworks/Client/Friends.cs +++ b/Facepunch.Steamworks/Client/Friends.cs @@ -40,6 +40,23 @@ namespace Facepunch.Steamworks client = c; client.RegisterCallback( OnPersonaStateChange ); + client.RegisterCallback( 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 ); + } } /// @@ -226,6 +243,9 @@ namespace Facepunch.Steamworks 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,