Unstable 1.1.14.0

This commit is contained in:
Markus Isberg
2023-10-02 16:43:54 +03:00
parent 94f5a93a0c
commit cf8f0de659
606 changed files with 21906 additions and 11456 deletions
+72 -23
View File
@@ -17,13 +17,17 @@ namespace Steamworks
{
internal static ISteamUser? Internal => Interface as ISteamUser;
internal override void InitializeInterface( bool server )
internal override bool InitializeInterface( bool server )
{
SetInterface( server, new ISteamUser( server ) );
if ( Interface is null || Interface.Self == IntPtr.Zero ) return false;
InstallEvents();
richPresence = new Dictionary<string, string>();
SampleRate = OptimalSampleRate;
return true;
}
static Dictionary<string, string>? richPresence;
@@ -39,11 +43,12 @@ namespace Steamworks
Dispatch.Install<MicroTxnAuthorizationResponse_t>( x => OnMicroTxnAuthorizationResponse?.Invoke( x.AppID, x.OrderID, x.Authorized != 0 ) );
Dispatch.Install<GameWebCallback_t>( x => OnGameWebCallback?.Invoke( x.URLUTF8() ) );
Dispatch.Install<GetAuthSessionTicketResponse_t>( x => OnGetAuthSessionTicketResponse?.Invoke( x ) );
Dispatch.Install<GetTicketForWebApiResponse_t>( x => OnGetAuthTicketForWebApiResponse?.Invoke( x ) );
Dispatch.Install<DurationControl_t>( x => OnDurationControl?.Invoke( new DurationControl { _inner = x } ) );
}
/// <summary>
/// Called when a connections to the Steam back-end has been established.
/// Invoked 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.
@@ -51,14 +56,14 @@ namespace Steamworks
public static event Action? OnSteamServersConnected;
/// <summary>
/// Called when a connection attempt has failed.
/// Invoked 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.
/// </summary>
public static event Action? OnSteamServerConnectFailure;
/// <summary>
/// Called if the client has lost connection to the Steam servers.
/// Invoked when the client has lost connection to the Steam servers.
/// Real-time services will be disabled until a matching OnSteamServersConnected has been posted.
/// </summary>
public static event Action? OnSteamServersDisconnected;
@@ -72,25 +77,30 @@ namespace Steamworks
public static event Action? OnClientGameServerDeny;
/// <summary>
/// Called whenever the users licenses (owned packages) changes.
/// Invoked whenever the users licenses (owned packages) changes.
/// </summary>
public static event Action? OnLicensesUpdated;
/// <summary>
/// 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
/// Invoked when an auth ticket has been validated.
/// The first parameter is the <see cref="SteamId"/> of this user
/// The second is the <see cref="SteamId"/> that owns the game, which will be different from the first
/// if the game is being borrowed via Steam Family Sharing.
/// </summary>
public static event Action<SteamId, SteamId, AuthResponse>? OnValidateAuthTicketResponse;
/// <summary>
/// Used internally for GetAuthSessionTicketAsync
/// Used internally for <see cref="GetAuthSessionTicketAsync(double)"/>.
/// </summary>
internal static event Action<GetAuthSessionTicketResponse_t>? OnGetAuthSessionTicketResponse;
/// <summary>
/// Used internally for <see cref="GetAuthTicketForWebApi(string)"/>.
/// </summary>
internal static event Action<GetTicketForWebApiResponse_t>? OnGetAuthTicketForWebApiResponse;
/// <summary>
/// Called when a user has responded to a microtransaction authorization request.
/// Invoked when a user has responded to a microtransaction authorization request.
/// ( appid, orderid, user authorized )
/// </summary>
public static event Action<AppId, ulong, bool>? OnMicroTxnAuthorizationResponse;
@@ -110,9 +120,6 @@ namespace Steamworks
/// </summary>
public static event Action<DurationControl>? OnDurationControl;
static bool _recordingVoice;
/// <summary>
@@ -120,7 +127,6 @@ namespace Steamworks
/// Once started, use GetAvailableVoice and GetVoice to get the data, and then call StopVoiceRecording
/// when the user has released their push-to-talk hotkey or the game session has completed.
/// </summary>
public static bool VoiceRecord
{
get => _recordingVoice;
@@ -134,7 +140,7 @@ namespace Steamworks
/// <summary>
/// Returns true if we have voice data waiting to be read
/// Returns true if we have voice data waiting to be read.
/// </summary>
public static bool HasVoiceData
{
@@ -304,16 +310,16 @@ namespace Steamworks
}
/// <summary>
/// Retrieve a authentication ticket to be sent to the entity who wishes to authenticate you.
/// Retrieve an authentication ticket to be sent to the entity who wishes to authenticate you.
/// </summary>
public static unsafe AuthTicket? GetAuthSessionTicket()
public static unsafe AuthTicket? GetAuthSessionTicket( NetIdentity identity )
{
var data = Helpers.TakeBuffer( 1024 );
fixed ( byte* b = data )
{
uint ticketLength = 0;
uint ticket = Internal?.GetAuthSessionTicket( (IntPtr)b, data.Length, ref ticketLength ) ?? 0;
uint ticket = Internal?.GetAuthSessionTicket( (IntPtr)b, data.Length, ref ticketLength, ref identity ) ?? 0;
if ( ticket == 0 )
return null;
@@ -326,13 +332,56 @@ namespace Steamworks
}
}
public static async Task<AuthTicketForWebApi?> GetAuthTicketForWebApi( string identity )
{
if ( Internal is null ) { return null; }
HAuthTicket handle = default;
AuthTicketForWebApi? ticket = null;
Result result = Result.Pending;
Action<GetTicketForWebApiResponse_t> responseHandler = response =>
{
if ( response.Ticket == handle ) { return; }
result = response.Result == Result.Pending
? Result.Fail
: response.Result;
ticket = result == Result.OK
? new AuthTicketForWebApi(
response.GubTicket.Take( response.Ticket ).ToArray(),
response.AuthTicket )
: null;
};
OnGetAuthTicketForWebApiResponse += responseHandler;
try
{
handle = Internal.GetAuthTicketForWebApi( identity );
if ( handle == 0 ) { return null; }
var timeout = DateTime.Now + TimeSpan.FromSeconds( 60f );
while ( result == Result.Pending && DateTime.Now < timeout )
{
await Task.Delay( 10 );
}
}
finally
{
OnGetAuthTicketForWebApiResponse -= responseHandler;
}
return ticket;
}
/// <summary>
/// Retrieve a authentication ticket to be sent to the entity who wishes to authenticate you.
/// This waits for a positive response from the backend before returning the ticket. This means
/// the ticket is definitely ready to go as soon as it returns. Will return null if the callback
/// the ticket is definitely ready to go as soon as it returns. Will return <see langword="null"/> if the callback
/// times out or returns negatively.
/// </summary>
public static async Task<AuthTicket?> GetAuthSessionTicketAsync( double timeoutSeconds = 10.0f )
public static async Task<AuthTicket?> GetAuthSessionTicketAsync( NetIdentity identity, double timeoutSeconds = 10.0f )
{
var result = Result.Pending;
AuthTicket? ticket = null;
@@ -348,7 +397,7 @@ namespace Steamworks
try
{
ticket = GetAuthSessionTicket();
ticket = GetAuthSessionTicket( identity );
if ( ticket == null )
return null;
@@ -518,4 +567,4 @@ namespace Steamworks
return new DurationControl { _inner = response.Value };
}
}
}
}