mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-12 22:58:01 +03:00
Keep the pipes
This commit is contained in:
parent
1aeeb6b932
commit
8d605e99fa
@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using SteamNative;
|
||||||
|
|
||||||
namespace Facepunch.Steamworks.Interop
|
namespace Facepunch.Steamworks.Interop
|
||||||
{
|
{
|
||||||
@ -26,6 +27,9 @@ namespace Facepunch.Steamworks.Interop
|
|||||||
|
|
||||||
private bool isServer;
|
private bool isServer;
|
||||||
|
|
||||||
|
private HSteamUser hUser;
|
||||||
|
private HSteamPipe hPipe;
|
||||||
|
|
||||||
internal bool InitClient()
|
internal bool InitClient()
|
||||||
{
|
{
|
||||||
isServer = false;
|
isServer = false;
|
||||||
@ -35,12 +39,12 @@ namespace Facepunch.Steamworks.Interop
|
|||||||
if ( !api.SteamAPI_Init() )
|
if ( !api.SteamAPI_Init() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var huser = api.SteamAPI_GetHSteamUser();
|
hUser = api.SteamAPI_GetHSteamUser();
|
||||||
var hpipe = api.SteamAPI_GetHSteamPipe();
|
hPipe = api.SteamAPI_GetHSteamPipe();
|
||||||
if ( hpipe == 0 )
|
if ( hPipe == 0 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
FillInterfaces( huser, hpipe );
|
FillInterfaces( hUser, hPipe );
|
||||||
|
|
||||||
// Ensure that the user has logged into Steam. This will always return true if the game is launched
|
// Ensure that the user has logged into Steam. This will always return true if the game is launched
|
||||||
// from Steam, but if Steam is at the login prompt when you run your game it will return false.
|
// from Steam, but if Steam is at the login prompt when you run your game it will return false.
|
||||||
@ -61,12 +65,12 @@ namespace Facepunch.Steamworks.Interop
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var user = api.SteamGameServer_GetHSteamUser();
|
hUser = api.SteamGameServer_GetHSteamUser();
|
||||||
var pipe = api.SteamGameServer_GetHSteamPipe();
|
hPipe = api.SteamGameServer_GetHSteamPipe();
|
||||||
if ( pipe == 0 )
|
if ( hPipe == 0 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
FillInterfaces( pipe, user );
|
FillInterfaces( hPipe, hUser );
|
||||||
|
|
||||||
if ( !gameServer.IsValid )
|
if ( !gameServer.IsValid )
|
||||||
{
|
{
|
||||||
@ -107,6 +111,21 @@ namespace Facepunch.Steamworks.Interop
|
|||||||
{
|
{
|
||||||
if ( client != null )
|
if ( client != null )
|
||||||
{
|
{
|
||||||
|
if ( hPipe != 0 )
|
||||||
|
{
|
||||||
|
if ( hUser != 0 )
|
||||||
|
{
|
||||||
|
client.ReleaseUser( hPipe, hUser );
|
||||||
|
hUser = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
client.BReleaseSteamPipe( hPipe );
|
||||||
|
hPipe = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !client.BShutdownIfAllPipesClosed() )
|
||||||
|
Console.WriteLine( "BShutdownIfAllPipesClosed returned false" );
|
||||||
|
|
||||||
client.Dispose();
|
client.Dispose();
|
||||||
client = null;
|
client = null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user