Release 1.9.7.0 - Summer Update 2025
This commit is contained in:
@@ -43,7 +43,7 @@ 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<GetTicketForWebApiResponse_t>( x => OnGetTicketForWebApiResponse?.Invoke( x ) );
|
||||
Dispatch.Install<DurationControl_t>( x => OnDurationControl?.Invoke( new DurationControl { _inner = x } ) );
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Steamworks
|
||||
public static event Action<SteamId, SteamId, AuthResponse>? OnValidateAuthTicketResponse;
|
||||
|
||||
/// <summary>
|
||||
/// Used internally for <see cref="GetAuthSessionTicketAsync(double)"/>.
|
||||
/// Used internally for <see cref="GetAuthSessionTicketAsync(NetIdentity, double)"/>.
|
||||
/// </summary>
|
||||
internal static event Action<GetAuthSessionTicketResponse_t>? OnGetAuthSessionTicketResponse;
|
||||
|
||||
@@ -99,6 +99,11 @@ namespace Steamworks
|
||||
/// </summary>
|
||||
internal static event Action<GetTicketForWebApiResponse_t>? OnGetAuthTicketForWebApiResponse;
|
||||
|
||||
/// <summary>
|
||||
/// Used internally for <see cref="GetAuthTicketForWebApiAsync(string, double)"/>.
|
||||
/// </summary>
|
||||
internal static event Action<GetTicketForWebApiResponse_t>? OnGetTicketForWebApiResponse;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when a user has responded to a microtransaction authorization request.
|
||||
/// ( appid, orderid, user authorized )
|
||||
@@ -332,49 +337,6 @@ 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
|
||||
@@ -424,6 +386,74 @@ namespace Steamworks
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve an authentication ticket to be sent to the entity who wishes to authenticate you.
|
||||
/// </summary>
|
||||
private static unsafe AuthTicket? GetAuthTicketForWebApi( string identity )
|
||||
{
|
||||
if ( Internal is null ) { return null; }
|
||||
uint ticket = Internal.GetAuthTicketForWebApi( identity );
|
||||
|
||||
if ( ticket == 0 )
|
||||
return null;
|
||||
|
||||
return new AuthTicket()
|
||||
{
|
||||
Handle = 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 <see langword="null"/> if the callback
|
||||
/// times out or returns negatively.
|
||||
/// </summary>
|
||||
public static async Task<AuthTicket?> GetAuthTicketForWebApiAsync( string identity, double timeoutSeconds = 10.0f )
|
||||
{
|
||||
if ( Internal is null ) { return null; }
|
||||
var result = Result.Pending;
|
||||
AuthTicket? ticket = null;
|
||||
var stopwatch = Stopwatch.StartNew();
|
||||
|
||||
void f( GetTicketForWebApiResponse_t t )
|
||||
{
|
||||
if ( ticket is null || t.AuthTicket != ticket.Handle ) return;
|
||||
result = t.Result;
|
||||
ticket.Data = t.GubTicket;
|
||||
}
|
||||
|
||||
OnGetTicketForWebApiResponse += f;
|
||||
|
||||
try
|
||||
{
|
||||
ticket = GetAuthTicketForWebApi( identity );
|
||||
if ( ticket == null )
|
||||
return null;
|
||||
|
||||
while ( result == Result.Pending )
|
||||
{
|
||||
await Task.Delay( 10 );
|
||||
|
||||
if ( stopwatch.Elapsed.TotalSeconds > timeoutSeconds )
|
||||
{
|
||||
ticket.Cancel();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if ( result == Result.OK )
|
||||
return ticket;
|
||||
|
||||
ticket.Cancel();
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
OnGetTicketForWebApiResponse -= f;
|
||||
}
|
||||
}
|
||||
|
||||
public static unsafe BeginAuthResult BeginAuthSession( byte[] ticketData, SteamId steamid )
|
||||
{
|
||||
fixed ( byte* ptr = ticketData )
|
||||
|
||||
Reference in New Issue
Block a user