diff --git a/Facepunch.Steamworks.Test/Server/Server.cs b/Facepunch.Steamworks.Test/Server/Server.cs index 6269550..66290ef 100644 --- a/Facepunch.Steamworks.Test/Server/Server.cs +++ b/Facepunch.Steamworks.Test/Server/Server.cs @@ -18,7 +18,7 @@ namespace Facepunch.Steamworks.Test [TestMethod] public void Init() { - using ( var server = new Facepunch.Steamworks.Server( 252490, 30001, 30002, 30003, false, "VersionString" ) ) + using ( var server = new Facepunch.Steamworks.Server( 252490, 30002, 30003, false, "VersionString" ) ) { Assert.IsTrue( server.IsValid ); } @@ -33,7 +33,7 @@ namespace Facepunch.Steamworks.Test var ticket = client.Auth.GetAuthSessionTicket(); var ticketBinary = ticket.Data; - using ( var server = new Facepunch.Steamworks.Server( 252490, 30001, 30002, 30003, true, "VersionString" ) ) + using ( var server = new Facepunch.Steamworks.Server( 252490, 30002, 30003, true, "VersionString" ) ) { server.LogOnAnonymous(); diff --git a/Facepunch.Steamworks/Client.cs b/Facepunch.Steamworks/Client.cs index 09d6eac..51b7102 100644 --- a/Facepunch.Steamworks/Client.cs +++ b/Facepunch.Steamworks/Client.cs @@ -91,8 +91,9 @@ namespace Facepunch.Steamworks native.api.SteamAPI_RunCallbacks(); Voice.Update(); - base.Update(); + + native.api.SteamAPI_RunCallbacks(); } public override void Dispose() @@ -105,6 +106,5 @@ namespace Facepunch.Steamworks base.Dispose(); } - } } diff --git a/Facepunch.Steamworks/Interop/Native.cs b/Facepunch.Steamworks/Interop/Native.cs index 3b84e4c..6c8b630 100644 --- a/Facepunch.Steamworks/Interop/Native.cs +++ b/Facepunch.Steamworks/Interop/Native.cs @@ -24,8 +24,12 @@ namespace Facepunch.Steamworks.Interop internal SteamNative.SteamGameServerStats gameServerStats; internal SteamNative.SteamRemoteStorage remoteStorage; + private bool isServer; + internal bool InitClient() { + isServer = false; + api = new SteamNative.SteamApi( (IntPtr) 1 ); if ( !api.SteamAPI_Init() ) @@ -48,6 +52,8 @@ namespace Facepunch.Steamworks.Interop internal bool InitServer( uint IpAddress /*uint32*/, ushort usPort /*uint16*/, ushort GamePort /*uint16*/, ushort QueryPort /*uint16*/, int eServerMode /*int*/, string pchVersionString /*const char **/) { + isServer = true; + api = new SteamNative.SteamApi( (IntPtr)1 ); if ( !api.SteamInternal_GameServer_Init( IpAddress, usPort, GamePort, QueryPort, eServerMode, pchVersionString ) ) @@ -155,6 +161,11 @@ namespace Facepunch.Steamworks.Interop if ( gameServer != null ) { + // + // Calling this can cause the process to hang + // + //gameServer.LogOff(); + gameServer.Dispose(); gameServer = null; } @@ -191,7 +202,11 @@ namespace Facepunch.Steamworks.Interop if ( api != null ) { - api.SteamAPI_Shutdown(); + if ( isServer ) + api.SteamGameServer_Shutdown(); + else + api.SteamAPI_Shutdown(); + api.Dispose(); api = null; } diff --git a/Facepunch.Steamworks/Server.cs b/Facepunch.Steamworks/Server.cs index 80e149f..22a6b98 100644 --- a/Facepunch.Steamworks/Server.cs +++ b/Facepunch.Steamworks/Server.cs @@ -98,6 +98,8 @@ namespace Facepunch.Steamworks native.api.SteamGameServer_RunCallbacks(); base.Update(); + + native.api.SteamGameServer_RunCallbacks(); } /// diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Interface.cs b/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Interface.cs index 6a5cb4e..d4ea285 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Interface.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Interface.cs @@ -663,6 +663,7 @@ namespace SteamNative void /*void*/ SteamApi_SteamAPI_UnregisterCallback( IntPtr /*void **/ pCallback ); bool /*bool*/ SteamApi_SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString ); void /*void*/ SteamApi_SteamAPI_Shutdown(); + void /*void*/ SteamApi_SteamGameServer_Shutdown(); HSteamUser /*(HSteamUser)*/ SteamApi_SteamAPI_GetHSteamUser(); HSteamPipe /*(HSteamPipe)*/ SteamApi_SteamAPI_GetHSteamPipe(); HSteamUser /*(HSteamUser)*/ SteamApi_SteamGameServer_GetHSteamUser(); diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Linux32.cs b/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Linux32.cs index d47f428..aaa6453 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Linux32.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Linux32.cs @@ -3986,6 +3986,10 @@ namespace SteamNative { Native.SteamApi.SteamAPI_Shutdown(); } + public virtual void /*void*/ SteamApi_SteamGameServer_Shutdown() + { + Native.SteamApi.SteamGameServer_Shutdown(); + } public virtual HSteamUser /*(HSteamUser)*/ SteamApi_SteamAPI_GetHSteamUser() { return Native.SteamApi.SteamAPI_GetHSteamUser(); @@ -5409,6 +5413,8 @@ namespace SteamNative internal static extern bool /*bool*/ SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString ); [DllImportAttribute( "libsteam_api.so", EntryPoint = "SteamAPI_Shutdown" )] internal static extern void /*void*/ SteamAPI_Shutdown(); + [DllImportAttribute( "libsteam_api.so", EntryPoint = "SteamGameServer_Shutdown" )] + internal static extern void /*void*/ SteamGameServer_Shutdown(); [DllImportAttribute( "libsteam_api.so", EntryPoint = "SteamAPI_GetHSteamUser" )] internal static extern HSteamUser /*(HSteamUser)*/ SteamAPI_GetHSteamUser(); [DllImportAttribute( "libsteam_api.so", EntryPoint = "SteamAPI_GetHSteamPipe" )] diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Linux64.cs b/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Linux64.cs index 652d9af..2008226 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Linux64.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Linux64.cs @@ -3986,6 +3986,10 @@ namespace SteamNative { Native.SteamApi.SteamAPI_Shutdown(); } + public virtual void /*void*/ SteamApi_SteamGameServer_Shutdown() + { + Native.SteamApi.SteamGameServer_Shutdown(); + } public virtual HSteamUser /*(HSteamUser)*/ SteamApi_SteamAPI_GetHSteamUser() { return Native.SteamApi.SteamAPI_GetHSteamUser(); @@ -5409,6 +5413,8 @@ namespace SteamNative internal static extern bool /*bool*/ SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString ); [DllImportAttribute( "libsteam_api64.so", EntryPoint = "SteamAPI_Shutdown" )] internal static extern void /*void*/ SteamAPI_Shutdown(); + [DllImportAttribute( "libsteam_api64.so", EntryPoint = "SteamGameServer_Shutdown" )] + internal static extern void /*void*/ SteamGameServer_Shutdown(); [DllImportAttribute( "libsteam_api64.so", EntryPoint = "SteamAPI_GetHSteamUser" )] internal static extern HSteamUser /*(HSteamUser)*/ SteamAPI_GetHSteamUser(); [DllImportAttribute( "libsteam_api64.so", EntryPoint = "SteamAPI_GetHSteamPipe" )] diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Mac.cs b/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Mac.cs index ae83311..430ea87 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Mac.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Mac.cs @@ -3986,6 +3986,10 @@ namespace SteamNative { Native.SteamApi.SteamAPI_Shutdown(); } + public virtual void /*void*/ SteamApi_SteamGameServer_Shutdown() + { + Native.SteamApi.SteamGameServer_Shutdown(); + } public virtual HSteamUser /*(HSteamUser)*/ SteamApi_SteamAPI_GetHSteamUser() { return Native.SteamApi.SteamAPI_GetHSteamUser(); @@ -5409,6 +5413,8 @@ namespace SteamNative internal static extern bool /*bool*/ SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString ); [DllImportAttribute( "libsteam_api.dylib", EntryPoint = "SteamAPI_Shutdown" )] internal static extern void /*void*/ SteamAPI_Shutdown(); + [DllImportAttribute( "libsteam_api.dylib", EntryPoint = "SteamGameServer_Shutdown" )] + internal static extern void /*void*/ SteamGameServer_Shutdown(); [DllImportAttribute( "libsteam_api.dylib", EntryPoint = "SteamAPI_GetHSteamUser" )] internal static extern HSteamUser /*(HSteamUser)*/ SteamAPI_GetHSteamUser(); [DllImportAttribute( "libsteam_api.dylib", EntryPoint = "SteamAPI_GetHSteamPipe" )] diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Win32.cs b/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Win32.cs index 65d577b..49fd296 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Win32.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Win32.cs @@ -3952,6 +3952,10 @@ namespace SteamNative { Native.SteamApi.SteamAPI_Shutdown(); } + public virtual void /*void*/ SteamApi_SteamGameServer_Shutdown() + { + Native.SteamApi.SteamGameServer_Shutdown(); + } public virtual HSteamUser /*(HSteamUser)*/ SteamApi_SteamAPI_GetHSteamUser() { return Native.SteamApi.SteamAPI_GetHSteamUser(); @@ -5375,6 +5379,8 @@ namespace SteamNative internal static extern bool /*bool*/ SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString ); [DllImportAttribute( "steam_api.dll", EntryPoint = "SteamAPI_Shutdown" )] internal static extern void /*void*/ SteamAPI_Shutdown(); + [DllImportAttribute( "steam_api.dll", EntryPoint = "SteamGameServer_Shutdown" )] + internal static extern void /*void*/ SteamGameServer_Shutdown(); [DllImportAttribute( "steam_api.dll", EntryPoint = "SteamAPI_GetHSteamUser" )] internal static extern HSteamUser /*(HSteamUser)*/ SteamAPI_GetHSteamUser(); [DllImportAttribute( "steam_api.dll", EntryPoint = "SteamAPI_GetHSteamPipe" )] diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Win64.cs b/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Win64.cs index 03f4284..94dba21 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Win64.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.Platform.Win64.cs @@ -3952,6 +3952,10 @@ namespace SteamNative { Native.SteamApi.SteamAPI_Shutdown(); } + public virtual void /*void*/ SteamApi_SteamGameServer_Shutdown() + { + Native.SteamApi.SteamGameServer_Shutdown(); + } public virtual HSteamUser /*(HSteamUser)*/ SteamApi_SteamAPI_GetHSteamUser() { return Native.SteamApi.SteamAPI_GetHSteamUser(); @@ -5375,6 +5379,8 @@ namespace SteamNative internal static extern bool /*bool*/ SteamInternal_GameServer_Init( uint /*uint32*/ unIP, ushort /*uint16*/ usPort, ushort /*uint16*/ usGamePort, ushort /*uint16*/ usQueryPort, int /*int*/ eServerMode, string /*const char **/ pchVersionString ); [DllImportAttribute( "steam_api64.dll", EntryPoint = "SteamAPI_Shutdown" )] internal static extern void /*void*/ SteamAPI_Shutdown(); + [DllImportAttribute( "steam_api64.dll", EntryPoint = "SteamGameServer_Shutdown" )] + internal static extern void /*void*/ SteamGameServer_Shutdown(); [DllImportAttribute( "steam_api64.dll", EntryPoint = "SteamAPI_GetHSteamUser" )] internal static extern HSteamUser /*(HSteamUser)*/ SteamAPI_GetHSteamUser(); [DllImportAttribute( "steam_api64.dll", EntryPoint = "SteamAPI_GetHSteamPipe" )] diff --git a/Facepunch.Steamworks/SteamNative/SteamNative.SteamApi.cs b/Facepunch.Steamworks/SteamNative/SteamNative.SteamApi.cs index b5ffad2..d017678 100644 --- a/Facepunch.Steamworks/SteamNative/SteamNative.SteamApi.cs +++ b/Facepunch.Steamworks/SteamNative/SteamNative.SteamApi.cs @@ -99,6 +99,12 @@ namespace SteamNative _pi.SteamApi_SteamGameServer_RunCallbacks(); } + // void + public void SteamGameServer_Shutdown() + { + _pi.SteamApi_SteamGameServer_Shutdown(); + } + // IntPtr public IntPtr SteamInternal_CreateInterface( string version /*const char **/ ) { diff --git a/Generator/CodeWriter.cs b/Generator/CodeWriter.cs index ed39734..4bad3e2 100644 --- a/Generator/CodeWriter.cs +++ b/Generator/CodeWriter.cs @@ -129,8 +129,13 @@ namespace Generator NeedsSelfPointer = false } ); - - + def.methods.Add( new SteamApiDefinition.MethodDef() + { + ClassName = "SteamApi", + Name = "SteamGameServer_Shutdown", + ReturnType = "void", + NeedsSelfPointer = false + } ); def.methods.Add( new SteamApiDefinition.MethodDef() {