From d211dd40e12e0883828a5cf8700cde81e5b27fe8 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Mon, 15 Apr 2019 10:39:54 +0100 Subject: [PATCH] User events --- Facepunch.Steamworks/Redux/Steam.cs | 1 + Facepunch.Steamworks/Redux/User.cs | 67 +++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 4 deletions(-) diff --git a/Facepunch.Steamworks/Redux/Steam.cs b/Facepunch.Steamworks/Redux/Steam.cs index 3454a48..a16e1c5 100644 --- a/Facepunch.Steamworks/Redux/Steam.cs +++ b/Facepunch.Steamworks/Redux/Steam.cs @@ -36,6 +36,7 @@ public static void Init( uint appid ) Parental.InstallEvents(); Music.InstallEvents(); Video.InstallEvents(); + User.InstallEvents(); } internal static void RegisterCallback( IntPtr intPtr, int callbackId ) diff --git a/Facepunch.Steamworks/Redux/User.cs b/Facepunch.Steamworks/Redux/User.cs index 79ad38c..68766cd 100644 --- a/Facepunch.Steamworks/Redux/User.cs +++ b/Facepunch.Steamworks/Redux/User.cs @@ -9,7 +9,8 @@ namespace Steamworks { /// - /// Undocumented Parental Settings + /// Functions for accessing and manipulating Steam user information. + /// This is also where the APIs for Steam Voice are exposed. /// public static class User { @@ -35,11 +36,69 @@ internal static Internal.ISteamUser Internal internal static void InstallEvents() { - // new Event( x => OnBroadcastStarted?.Invoke() ); - // new Event( x => OnBroadcastStopped?.Invoke( x.Result ) ); + new Event( x => OnSteamServersConnected?.Invoke() ); + new Event( x => OnSteamServerConnectFailure?.Invoke() ); + new Event( x => OnSteamServersDisconnected?.Invoke() ); + new Event( x => OnClientGameServerDeny?.Invoke() ); + new Event( x => OnLicensesUpdated?.Invoke() ); + new Event( x => OnValidateAuthTicketResponse?.Invoke( x.SteamID, x.OwnerSteamID, x.AuthSessionResponse ) ); + new Event( x => OnMicroTxnAuthorizationResponse?.Invoke( x.AppID, x.OrderID, x.Authorized != 0 ) ); + new Event( x => OnGameWebCallback?.Invoke( x.URL ) ); } - // public static event Action OnBroadcastStarted; + /// + /// Called when a connections to the Steam back-end has been established. + /// This means the Steam client now has a working connection to the Steam servers. + /// Usually this will have occurred before the game has launched, and should only be seen if the + /// user has dropped connection due to a networking issue or a Steam server update. + /// + public static event Action OnSteamServersConnected; + + /// + /// Called when a connection attempt has failed. + /// This will occur periodically if the Steam client is not connected, + /// and has failed when retrying to establish a connection. + /// + public static event Action OnSteamServerConnectFailure; + + /// + /// Called if the client has lost connection to the Steam servers. + /// Real-time services will be disabled until a matching OnSteamServersConnected has been posted. + /// + public static event Action OnSteamServersDisconnected; + + /// + /// Sent by the Steam server to the client telling it to disconnect from the specified game server, + /// which it may be in the process of or already connected to. + /// The game client should immediately disconnect upon receiving this message. + /// This can usually occur if the user doesn't have rights to play on the game server. + /// + public static event Action OnClientGameServerDeny; + + /// + /// Called whenever the users licenses (owned packages) changes. + /// + public static event Action OnLicensesUpdated; + + /// + /// Called when an auth ticket has been validated. + /// The first parameter is the steamid of this user + /// The second is the Steam ID that owns the game, this will be different from the first if the game is being borrowed via Steam Family Sharing + /// + public static event Action OnValidateAuthTicketResponse; + + /// + /// Called when a user has responded to a microtransaction authorization request. + /// ( appid, orderid, user authorized ) + /// + public static event Action OnMicroTxnAuthorizationResponse; + + /// + /// Sent to your game in response to a steam://gamewebcallback/ command from a user clicking a link in the Steam overlay browser. + /// You can use this to add support for external site signups where you want to pop back into the browser after some web page + /// signup sequence, and optionally get back some detail about that. + /// + public static event Action OnGameWebCallback; /// /// Checks if the current user's Steam client is connected to the Steam servers.