mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-24 13:45:37 +03:00
Cleanup
This commit is contained in:
parent
2caf093e6d
commit
3844c74d9c
@ -46,13 +46,13 @@ public void ClientAuthSessionTicket()
|
||||
{
|
||||
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
||||
{
|
||||
var ticket = client.GetAuthSessionTicket();
|
||||
var ticket = client.Auth.GetAuthSessionTicket();
|
||||
|
||||
Assert.IsTrue( ticket != null );
|
||||
Assert.IsTrue( ticket.Handle != 0 );
|
||||
Assert.IsTrue( ticket.Data.Length > 0 );
|
||||
|
||||
client.CancelAuthTicket( ticket );
|
||||
client.Auth.CancelAuthTicket( ticket );
|
||||
|
||||
Assert.IsTrue( ticket.Handle == 0 );
|
||||
}
|
||||
|
@ -7,7 +7,25 @@ namespace Facepunch.Steamworks
|
||||
{
|
||||
public partial class Client : IDisposable
|
||||
{
|
||||
public class AuthTicket
|
||||
Auth _auth;
|
||||
|
||||
public Auth Auth
|
||||
{
|
||||
get
|
||||
{
|
||||
if ( _auth == null )
|
||||
_auth = new Auth{ client = this };
|
||||
|
||||
return _auth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Auth
|
||||
{
|
||||
internal Client client;
|
||||
|
||||
public class Ticket
|
||||
{
|
||||
public byte[] Data;
|
||||
public uint Handle;
|
||||
@ -17,19 +35,19 @@ public class AuthTicket
|
||||
/// Creates an auth ticket.
|
||||
/// Which you can send to a server to authenticate that you are who you say you are.
|
||||
/// </summary>
|
||||
public unsafe AuthTicket GetAuthSessionTicket()
|
||||
public unsafe Ticket GetAuthSessionTicket()
|
||||
{
|
||||
var data = new byte[1024];
|
||||
|
||||
|
||||
fixed ( byte* b = data )
|
||||
{
|
||||
uint ticketLength = 0;
|
||||
uint ticket = _user.GetAuthSessionTicket( (IntPtr) b, data.Length, ref ticketLength );
|
||||
uint ticket = client._user.GetAuthSessionTicket( (IntPtr) b, data.Length, ref ticketLength );
|
||||
|
||||
if ( ticket == 0 )
|
||||
return null;
|
||||
|
||||
return new AuthTicket()
|
||||
return new Ticket()
|
||||
{
|
||||
Data = data.Take( (int)ticketLength ).ToArray(),
|
||||
Handle = ticket
|
||||
@ -41,9 +59,9 @@ public unsafe AuthTicket GetAuthSessionTicket()
|
||||
/// Cancels a ticket.
|
||||
/// You should cancel your ticket when you close the game or leave a server.
|
||||
/// </summary>
|
||||
public void CancelAuthTicket( AuthTicket ticket )
|
||||
public void CancelAuthTicket( Ticket ticket )
|
||||
{
|
||||
_user.CancelAuthTicket( ticket.Handle );
|
||||
client._user.CancelAuthTicket( ticket.Handle );
|
||||
ticket.Handle = 0;
|
||||
ticket.Data = null;
|
||||
}
|
||||
|
@ -7,11 +7,12 @@ namespace Facepunch.Steamworks
|
||||
{
|
||||
public partial class Client : IDisposable
|
||||
{
|
||||
private Valve.Steamworks.ISteamClient _client;
|
||||
private uint _hpipe;
|
||||
private uint _huser;
|
||||
private Valve.Steamworks.ISteamUser _user;
|
||||
private Valve.Steamworks.ISteamFriends _friends;
|
||||
|
||||
internal Valve.Steamworks.ISteamClient _client;
|
||||
internal Valve.Steamworks.ISteamUser _user;
|
||||
internal Valve.Steamworks.ISteamFriends _friends;
|
||||
|
||||
/// <summary>
|
||||
/// Current running program's AppId
|
||||
|
Loading…
Reference in New Issue
Block a user