diff --git a/Facepunch.Steamworks.Test/Server/Server.cs b/Facepunch.Steamworks.Test/Server/Server.cs
index 0d85f9c..88b568b 100644
--- a/Facepunch.Steamworks.Test/Server/Server.cs
+++ b/Facepunch.Steamworks.Test/Server/Server.cs
@@ -14,10 +14,52 @@ public class Server
[TestMethod]
public void Init()
{
- using ( var server = new Facepunch.Steamworks.Server( 252490, 0, 20216, 20816, 20817, false, "VersionString" ) )
+ using ( var server = new Facepunch.Steamworks.Server( 252490, 30000, 30001, 30002, 30003, false, "VersionString" ) )
{
Assert.IsTrue( server.Valid );
}
}
+
+ [TestMethod]
+ public void AuthCallback()
+ {
+ using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
+ {
+ Assert.IsTrue( client.Valid );
+
+ var ticket = client.Auth.GetAuthSessionTicket();
+ var ticketBinary = ticket.Data;
+
+ using ( var server = new Facepunch.Steamworks.Server( 252490, 30000, 30001, 30002, 30003, false, "VersionString" ) )
+ {
+ Assert.IsTrue( server.Valid );
+
+ for ( int i = 0; i < 16; i++ )
+ {
+ System.Threading.Thread.Sleep( 10 );
+ server.Update();
+ client.Update();
+ }
+
+ if ( !server.Auth.StartSession( ticketBinary, client.SteamId ) )
+ {
+ Assert.Fail( "Start Session returned false" );
+ }
+
+ for( int i = 0; i<16; i++ )
+ {
+ System.Threading.Thread.Sleep( 10 );
+ server.Update();
+ client.Update();
+ }
+
+ //
+ // Client cancels ticket
+ //
+ ticket.Cancel();
+
+ }
+ }
+ }
}
}
diff --git a/Facepunch.Steamworks/Facepunch.Steamworks.csproj b/Facepunch.Steamworks/Facepunch.Steamworks.csproj
index d70f83a..c9738ce 100644
--- a/Facepunch.Steamworks/Facepunch.Steamworks.csproj
+++ b/Facepunch.Steamworks/Facepunch.Steamworks.csproj
@@ -132,10 +132,9 @@
+
-
-
-
+
diff --git a/Facepunch.Steamworks/Server.cs b/Facepunch.Steamworks/Server.cs
index b99976b..ae130a3 100644
--- a/Facepunch.Steamworks/Server.cs
+++ b/Facepunch.Steamworks/Server.cs
@@ -101,12 +101,7 @@ public enum MessageType : int
public Server( uint appId, uint IpAddress, ushort SteamPort, ushort GamePort, ushort QueryPort, bool Secure, string VersionString )
{
- if ( !Valve.Interop.NativeEntrypoints.Extended.SteamInternal_GameServer_Init( IpAddress, SteamPort, GamePort, QueryPort, Secure ? 3 : 2 , VersionString ) )
- {
- return;
- }
-
- //Valve.Steamworks.SteamAPI.Init( appId );
+ Valve.Interop.NativeEntrypoints.Extended.SteamInternal_GameServer_Init( IpAddress, SteamPort, GamePort, QueryPort, Secure ? 3 : 2, VersionString );
native = new Internal();
diff --git a/Facepunch.Steamworks/Server/Auth.cs b/Facepunch.Steamworks/Server/Auth.cs
new file mode 100644
index 0000000..9eb74df
--- /dev/null
+++ b/Facepunch.Steamworks/Server/Auth.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Facepunch.Steamworks
+{
+ public partial class Server
+ {
+ ServerAuth _auth;
+
+ public ServerAuth Auth
+ {
+ get
+ {
+ if ( _auth == null )
+ _auth = new ServerAuth { server = this };
+
+ return _auth;
+ }
+ }
+ }
+
+ public class ServerAuth
+ {
+ internal Server server;
+
+ ///
+ /// Start authorizing a ticket
+ ///
+ public unsafe bool StartSession( byte[] data, ulong steamid )
+ {
+ fixed ( byte* p = data )
+ {
+ var result = (Valve.Steamworks.EBeginAuthSessionResult) server.native.gameServer.BeginAuthSession( (IntPtr)p, data.Length, steamid );
+
+ if ( result == Valve.Steamworks.EBeginAuthSessionResult.k_EBeginAuthSessionResultOK )
+ return true;
+
+ return false;
+ }
+ }
+
+ public void EndSession( ulong steamid )
+ {
+ server.native.gameServer.EndAuthSession( steamid );
+ }
+
+ }
+}