mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-25 06:05:46 +03:00
expose GetAuthSessionTicketResponse
This commit is contained in:
parent
5c9e239bc6
commit
ac44bb2293
@ -182,5 +182,45 @@ public void AuthenticateAServer()
|
||||
Assert.IsFalse( isAuthed );
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WaitForAuthTicketValidation()
|
||||
{
|
||||
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
||||
using ( var server = new Facepunch.Steamworks.Server( 252490, new ServerInit( "rust", "Rust" ) ) )
|
||||
{
|
||||
Assert.IsTrue( client.IsValid );
|
||||
Assert.IsTrue( server.IsValid );
|
||||
|
||||
server.LogOnAnonymous();
|
||||
|
||||
bool clientAuthed = false;
|
||||
bool serverAuthed = false;
|
||||
|
||||
client.Auth.OnGetAuthSessionTicketResponse += ( uint handle, bool authed ) => {
|
||||
clientAuthed = authed;
|
||||
};
|
||||
|
||||
server.Auth.OnGetAuthSessionTicketResponse += ( uint handle, bool authed ) => {
|
||||
serverAuthed = authed;
|
||||
};
|
||||
|
||||
var clientTicket = client.Auth.GetAuthSessionTicket();
|
||||
var serverTicket = server.Auth.GetAuthSessionTicket();
|
||||
|
||||
for ( int i = 0; i < 100; i++ )
|
||||
{
|
||||
System.Threading.Thread.Sleep( 16 );
|
||||
server.Update();
|
||||
client.Update();
|
||||
|
||||
if ( clientAuthed && serverAuthed )
|
||||
break;
|
||||
}
|
||||
|
||||
Assert.IsTrue( clientAuthed );
|
||||
Assert.IsTrue( serverAuthed );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ public ClientAuth( Client client )
|
||||
{
|
||||
_client = client;
|
||||
_client.RegisterCallback<SteamNative.ValidateAuthTicketResponse_t>( OnAuthTicketValidate );
|
||||
_client.RegisterCallback<SteamNative.GetAuthSessionTicketResponse_t>( OnGetAuthSessionTicketResponseThing );
|
||||
}
|
||||
|
||||
public unsafe override Ticket GetAuthSessionTicket()
|
||||
|
@ -45,6 +45,17 @@ internal void OnAuthTicketValidate( SteamNative.ValidateAuthTicketResponse_t dat
|
||||
OnAuthChange( data.SteamID, data.OwnerSteamID, (AuthStatus) data.AuthSessionResponse );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is called when your locally generated auth ticket has been validated by Steam
|
||||
/// </summary>
|
||||
public Action<uint, bool> OnGetAuthSessionTicketResponse;
|
||||
|
||||
internal void OnGetAuthSessionTicketResponseThing( SteamNative.GetAuthSessionTicketResponse_t data )
|
||||
{
|
||||
if ( OnGetAuthSessionTicketResponse != null )
|
||||
OnGetAuthSessionTicketResponse( data.AuthTicket, data.Result == SteamNative.Result.OK );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An auth ticket for the local client/server (never remote)
|
||||
/// You should not cancel this ticket until you are disconnected from the remote user
|
||||
|
@ -11,6 +11,7 @@ public ServerAuth( Server server )
|
||||
{
|
||||
_server = server;
|
||||
_server.RegisterCallback<SteamNative.ValidateAuthTicketResponse_t>( OnAuthTicketValidate );
|
||||
_server.RegisterCallback<SteamNative.GetAuthSessionTicketResponse_t>( OnGetAuthSessionTicketResponseThing );
|
||||
}
|
||||
|
||||
public unsafe override Ticket GetAuthSessionTicket()
|
||||
|
Loading…
Reference in New Issue
Block a user