mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-13 07:08:05 +03:00
Shutdown server properly
This commit is contained in:
parent
1b4f5b91aa
commit
f048730edd
@ -18,7 +18,7 @@ namespace Facepunch.Steamworks.Test
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Init()
|
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 );
|
Assert.IsTrue( server.IsValid );
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ namespace Facepunch.Steamworks.Test
|
|||||||
var ticket = client.Auth.GetAuthSessionTicket();
|
var ticket = client.Auth.GetAuthSessionTicket();
|
||||||
var ticketBinary = ticket.Data;
|
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();
|
server.LogOnAnonymous();
|
||||||
|
|
||||||
|
@ -91,8 +91,9 @@ namespace Facepunch.Steamworks
|
|||||||
native.api.SteamAPI_RunCallbacks();
|
native.api.SteamAPI_RunCallbacks();
|
||||||
|
|
||||||
Voice.Update();
|
Voice.Update();
|
||||||
|
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
|
native.api.SteamAPI_RunCallbacks();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
@ -105,6 +106,5 @@ namespace Facepunch.Steamworks
|
|||||||
|
|
||||||
base.Dispose();
|
base.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,12 @@ namespace Facepunch.Steamworks.Interop
|
|||||||
internal SteamNative.SteamGameServerStats gameServerStats;
|
internal SteamNative.SteamGameServerStats gameServerStats;
|
||||||
internal SteamNative.SteamRemoteStorage remoteStorage;
|
internal SteamNative.SteamRemoteStorage remoteStorage;
|
||||||
|
|
||||||
|
private bool isServer;
|
||||||
|
|
||||||
internal bool InitClient()
|
internal bool InitClient()
|
||||||
{
|
{
|
||||||
|
isServer = false;
|
||||||
|
|
||||||
api = new SteamNative.SteamApi( (IntPtr) 1 );
|
api = new SteamNative.SteamApi( (IntPtr) 1 );
|
||||||
|
|
||||||
if ( !api.SteamAPI_Init() )
|
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 **/)
|
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 );
|
api = new SteamNative.SteamApi( (IntPtr)1 );
|
||||||
|
|
||||||
if ( !api.SteamInternal_GameServer_Init( IpAddress, usPort, GamePort, QueryPort, eServerMode, pchVersionString ) )
|
if ( !api.SteamInternal_GameServer_Init( IpAddress, usPort, GamePort, QueryPort, eServerMode, pchVersionString ) )
|
||||||
@ -155,6 +161,11 @@ namespace Facepunch.Steamworks.Interop
|
|||||||
|
|
||||||
if ( gameServer != null )
|
if ( gameServer != null )
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
// Calling this can cause the process to hang
|
||||||
|
//
|
||||||
|
//gameServer.LogOff();
|
||||||
|
|
||||||
gameServer.Dispose();
|
gameServer.Dispose();
|
||||||
gameServer = null;
|
gameServer = null;
|
||||||
}
|
}
|
||||||
@ -191,7 +202,11 @@ namespace Facepunch.Steamworks.Interop
|
|||||||
|
|
||||||
if ( api != null )
|
if ( api != null )
|
||||||
{
|
{
|
||||||
|
if ( isServer )
|
||||||
|
api.SteamGameServer_Shutdown();
|
||||||
|
else
|
||||||
api.SteamAPI_Shutdown();
|
api.SteamAPI_Shutdown();
|
||||||
|
|
||||||
api.Dispose();
|
api.Dispose();
|
||||||
api = null;
|
api = null;
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,8 @@ namespace Facepunch.Steamworks
|
|||||||
native.api.SteamGameServer_RunCallbacks();
|
native.api.SteamGameServer_RunCallbacks();
|
||||||
|
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
|
native.api.SteamGameServer_RunCallbacks();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -663,6 +663,7 @@ namespace SteamNative
|
|||||||
void /*void*/ SteamApi_SteamAPI_UnregisterCallback( IntPtr /*void **/ pCallback );
|
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 );
|
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_SteamAPI_Shutdown();
|
||||||
|
void /*void*/ SteamApi_SteamGameServer_Shutdown();
|
||||||
HSteamUser /*(HSteamUser)*/ SteamApi_SteamAPI_GetHSteamUser();
|
HSteamUser /*(HSteamUser)*/ SteamApi_SteamAPI_GetHSteamUser();
|
||||||
HSteamPipe /*(HSteamPipe)*/ SteamApi_SteamAPI_GetHSteamPipe();
|
HSteamPipe /*(HSteamPipe)*/ SteamApi_SteamAPI_GetHSteamPipe();
|
||||||
HSteamUser /*(HSteamUser)*/ SteamApi_SteamGameServer_GetHSteamUser();
|
HSteamUser /*(HSteamUser)*/ SteamApi_SteamGameServer_GetHSteamUser();
|
||||||
|
@ -3986,6 +3986,10 @@ namespace SteamNative
|
|||||||
{
|
{
|
||||||
Native.SteamApi.SteamAPI_Shutdown();
|
Native.SteamApi.SteamAPI_Shutdown();
|
||||||
}
|
}
|
||||||
|
public virtual void /*void*/ SteamApi_SteamGameServer_Shutdown()
|
||||||
|
{
|
||||||
|
Native.SteamApi.SteamGameServer_Shutdown();
|
||||||
|
}
|
||||||
public virtual HSteamUser /*(HSteamUser)*/ SteamApi_SteamAPI_GetHSteamUser()
|
public virtual HSteamUser /*(HSteamUser)*/ SteamApi_SteamAPI_GetHSteamUser()
|
||||||
{
|
{
|
||||||
return Native.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 );
|
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" )]
|
[DllImportAttribute( "libsteam_api.so", EntryPoint = "SteamAPI_Shutdown" )]
|
||||||
internal static extern void /*void*/ 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" )]
|
[DllImportAttribute( "libsteam_api.so", EntryPoint = "SteamAPI_GetHSteamUser" )]
|
||||||
internal static extern HSteamUser /*(HSteamUser)*/ SteamAPI_GetHSteamUser();
|
internal static extern HSteamUser /*(HSteamUser)*/ SteamAPI_GetHSteamUser();
|
||||||
[DllImportAttribute( "libsteam_api.so", EntryPoint = "SteamAPI_GetHSteamPipe" )]
|
[DllImportAttribute( "libsteam_api.so", EntryPoint = "SteamAPI_GetHSteamPipe" )]
|
||||||
|
@ -3986,6 +3986,10 @@ namespace SteamNative
|
|||||||
{
|
{
|
||||||
Native.SteamApi.SteamAPI_Shutdown();
|
Native.SteamApi.SteamAPI_Shutdown();
|
||||||
}
|
}
|
||||||
|
public virtual void /*void*/ SteamApi_SteamGameServer_Shutdown()
|
||||||
|
{
|
||||||
|
Native.SteamApi.SteamGameServer_Shutdown();
|
||||||
|
}
|
||||||
public virtual HSteamUser /*(HSteamUser)*/ SteamApi_SteamAPI_GetHSteamUser()
|
public virtual HSteamUser /*(HSteamUser)*/ SteamApi_SteamAPI_GetHSteamUser()
|
||||||
{
|
{
|
||||||
return Native.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 );
|
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" )]
|
[DllImportAttribute( "libsteam_api64.so", EntryPoint = "SteamAPI_Shutdown" )]
|
||||||
internal static extern void /*void*/ 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" )]
|
[DllImportAttribute( "libsteam_api64.so", EntryPoint = "SteamAPI_GetHSteamUser" )]
|
||||||
internal static extern HSteamUser /*(HSteamUser)*/ SteamAPI_GetHSteamUser();
|
internal static extern HSteamUser /*(HSteamUser)*/ SteamAPI_GetHSteamUser();
|
||||||
[DllImportAttribute( "libsteam_api64.so", EntryPoint = "SteamAPI_GetHSteamPipe" )]
|
[DllImportAttribute( "libsteam_api64.so", EntryPoint = "SteamAPI_GetHSteamPipe" )]
|
||||||
|
@ -3986,6 +3986,10 @@ namespace SteamNative
|
|||||||
{
|
{
|
||||||
Native.SteamApi.SteamAPI_Shutdown();
|
Native.SteamApi.SteamAPI_Shutdown();
|
||||||
}
|
}
|
||||||
|
public virtual void /*void*/ SteamApi_SteamGameServer_Shutdown()
|
||||||
|
{
|
||||||
|
Native.SteamApi.SteamGameServer_Shutdown();
|
||||||
|
}
|
||||||
public virtual HSteamUser /*(HSteamUser)*/ SteamApi_SteamAPI_GetHSteamUser()
|
public virtual HSteamUser /*(HSteamUser)*/ SteamApi_SteamAPI_GetHSteamUser()
|
||||||
{
|
{
|
||||||
return Native.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 );
|
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" )]
|
[DllImportAttribute( "libsteam_api.dylib", EntryPoint = "SteamAPI_Shutdown" )]
|
||||||
internal static extern void /*void*/ 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" )]
|
[DllImportAttribute( "libsteam_api.dylib", EntryPoint = "SteamAPI_GetHSteamUser" )]
|
||||||
internal static extern HSteamUser /*(HSteamUser)*/ SteamAPI_GetHSteamUser();
|
internal static extern HSteamUser /*(HSteamUser)*/ SteamAPI_GetHSteamUser();
|
||||||
[DllImportAttribute( "libsteam_api.dylib", EntryPoint = "SteamAPI_GetHSteamPipe" )]
|
[DllImportAttribute( "libsteam_api.dylib", EntryPoint = "SteamAPI_GetHSteamPipe" )]
|
||||||
|
@ -3952,6 +3952,10 @@ namespace SteamNative
|
|||||||
{
|
{
|
||||||
Native.SteamApi.SteamAPI_Shutdown();
|
Native.SteamApi.SteamAPI_Shutdown();
|
||||||
}
|
}
|
||||||
|
public virtual void /*void*/ SteamApi_SteamGameServer_Shutdown()
|
||||||
|
{
|
||||||
|
Native.SteamApi.SteamGameServer_Shutdown();
|
||||||
|
}
|
||||||
public virtual HSteamUser /*(HSteamUser)*/ SteamApi_SteamAPI_GetHSteamUser()
|
public virtual HSteamUser /*(HSteamUser)*/ SteamApi_SteamAPI_GetHSteamUser()
|
||||||
{
|
{
|
||||||
return Native.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 );
|
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" )]
|
[DllImportAttribute( "steam_api.dll", EntryPoint = "SteamAPI_Shutdown" )]
|
||||||
internal static extern void /*void*/ 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" )]
|
[DllImportAttribute( "steam_api.dll", EntryPoint = "SteamAPI_GetHSteamUser" )]
|
||||||
internal static extern HSteamUser /*(HSteamUser)*/ SteamAPI_GetHSteamUser();
|
internal static extern HSteamUser /*(HSteamUser)*/ SteamAPI_GetHSteamUser();
|
||||||
[DllImportAttribute( "steam_api.dll", EntryPoint = "SteamAPI_GetHSteamPipe" )]
|
[DllImportAttribute( "steam_api.dll", EntryPoint = "SteamAPI_GetHSteamPipe" )]
|
||||||
|
@ -3952,6 +3952,10 @@ namespace SteamNative
|
|||||||
{
|
{
|
||||||
Native.SteamApi.SteamAPI_Shutdown();
|
Native.SteamApi.SteamAPI_Shutdown();
|
||||||
}
|
}
|
||||||
|
public virtual void /*void*/ SteamApi_SteamGameServer_Shutdown()
|
||||||
|
{
|
||||||
|
Native.SteamApi.SteamGameServer_Shutdown();
|
||||||
|
}
|
||||||
public virtual HSteamUser /*(HSteamUser)*/ SteamApi_SteamAPI_GetHSteamUser()
|
public virtual HSteamUser /*(HSteamUser)*/ SteamApi_SteamAPI_GetHSteamUser()
|
||||||
{
|
{
|
||||||
return Native.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 );
|
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" )]
|
[DllImportAttribute( "steam_api64.dll", EntryPoint = "SteamAPI_Shutdown" )]
|
||||||
internal static extern void /*void*/ 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" )]
|
[DllImportAttribute( "steam_api64.dll", EntryPoint = "SteamAPI_GetHSteamUser" )]
|
||||||
internal static extern HSteamUser /*(HSteamUser)*/ SteamAPI_GetHSteamUser();
|
internal static extern HSteamUser /*(HSteamUser)*/ SteamAPI_GetHSteamUser();
|
||||||
[DllImportAttribute( "steam_api64.dll", EntryPoint = "SteamAPI_GetHSteamPipe" )]
|
[DllImportAttribute( "steam_api64.dll", EntryPoint = "SteamAPI_GetHSteamPipe" )]
|
||||||
|
@ -99,6 +99,12 @@ namespace SteamNative
|
|||||||
_pi.SteamApi_SteamGameServer_RunCallbacks();
|
_pi.SteamApi_SteamGameServer_RunCallbacks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// void
|
||||||
|
public void SteamGameServer_Shutdown()
|
||||||
|
{
|
||||||
|
_pi.SteamApi_SteamGameServer_Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
// IntPtr
|
// IntPtr
|
||||||
public IntPtr SteamInternal_CreateInterface( string version /*const char **/ )
|
public IntPtr SteamInternal_CreateInterface( string version /*const char **/ )
|
||||||
{
|
{
|
||||||
|
@ -129,8 +129,13 @@ namespace Generator
|
|||||||
NeedsSelfPointer = false
|
NeedsSelfPointer = false
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
def.methods.Add( new SteamApiDefinition.MethodDef()
|
||||||
|
{
|
||||||
|
ClassName = "SteamApi",
|
||||||
|
Name = "SteamGameServer_Shutdown",
|
||||||
|
ReturnType = "void",
|
||||||
|
NeedsSelfPointer = false
|
||||||
|
} );
|
||||||
|
|
||||||
def.methods.Add( new SteamApiDefinition.MethodDef()
|
def.methods.Add( new SteamApiDefinition.MethodDef()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user