mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-05-31 15:57:44 +03:00
Added Steamworks.Realm
This commit is contained in:
parent
d1cc0da526
commit
a0d9fdeab1
@ -29,7 +29,6 @@ namespace Steamworks
|
|||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
|
||||||
|
|
||||||
SteamApps.InstallEvents();
|
SteamApps.InstallEvents();
|
||||||
SteamUtils.InstallEvents();
|
SteamUtils.InstallEvents();
|
||||||
SteamParental.InstallEvents();
|
SteamParental.InstallEvents();
|
||||||
@ -143,5 +142,7 @@ namespace Steamworks
|
|||||||
/// returns the appID of the current process
|
/// returns the appID of the current process
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static AppId AppId { get; internal set; }
|
public static AppId AppId { get; internal set; }
|
||||||
|
|
||||||
|
public static IDisposable Push() => Realm.Client();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -35,7 +35,6 @@ namespace Steamworks
|
|||||||
{
|
{
|
||||||
ValidateAuthTicketResponse_t.Install( x => OnValidateAuthTicketResponse?.Invoke( x.SteamID, x.OwnerSteamID, x.AuthSessionResponse ), true );
|
ValidateAuthTicketResponse_t.Install( x => OnValidateAuthTicketResponse?.Invoke( x.SteamID, x.OwnerSteamID, x.AuthSessionResponse ), true );
|
||||||
|
|
||||||
SteamServerInventory.InstallEvents();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -87,10 +86,10 @@ namespace Steamworks
|
|||||||
|
|
||||||
_internal = null;
|
_internal = null;
|
||||||
|
|
||||||
SteamServerInventory.Shutdown();
|
|
||||||
SteamGameServer.Shutdown();
|
|
||||||
SteamNetworkingUtils.Shutdown();
|
SteamNetworkingUtils.Shutdown();
|
||||||
SteamNetworkingSockets.Shutdown();
|
SteamNetworkingSockets.Shutdown();
|
||||||
|
|
||||||
|
SteamGameServer.Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -282,7 +281,7 @@ namespace Steamworks
|
|||||||
/// any time a player's name or score changes. This keeps the information shown
|
/// any time a player's name or score changes. This keeps the information shown
|
||||||
/// to server queries up to date.
|
/// to server queries up to date.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void UpdatePlayer( ulong steamid, string name, int score )
|
public static void UpdatePlayer( SteamId steamid, string name, int score )
|
||||||
{
|
{
|
||||||
Internal.BUpdateUserData( steamid, name, (uint)score );
|
Internal.BUpdateUserData( steamid, name, (uint)score );
|
||||||
}
|
}
|
||||||
@ -315,7 +314,7 @@ namespace Steamworks
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Start authorizing a ticket. This user isn't authorized yet. Wait for a call to OnAuthChange.
|
/// Start authorizing a ticket. This user isn't authorized yet. Wait for a call to OnAuthChange.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static unsafe bool BeginAuthSession( byte[] data, ulong steamid )
|
public static unsafe bool BeginAuthSession( byte[] data, SteamId steamid )
|
||||||
{
|
{
|
||||||
fixed ( byte* p = data )
|
fixed ( byte* p = data )
|
||||||
{
|
{
|
||||||
@ -331,7 +330,7 @@ namespace Steamworks
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Forget this guy. They're no longer in the game.
|
/// Forget this guy. They're no longer in the game.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void EndSession( ulong steamid )
|
public static void EndSession( SteamId steamid )
|
||||||
{
|
{
|
||||||
Internal.EndAuthSession( steamid );
|
Internal.EndAuthSession( steamid );
|
||||||
}
|
}
|
||||||
@ -374,5 +373,7 @@ namespace Steamworks
|
|||||||
Internal.HandleIncomingPacket( (IntPtr)ptr, size, address, port );
|
Internal.HandleIncomingPacket( (IntPtr)ptr, size, address, port );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IDisposable Push() => Realm.Server();
|
||||||
}
|
}
|
||||||
}
|
}
|
43
Facepunch.Steamworks/Utility/Realm.cs
Normal file
43
Facepunch.Steamworks/Utility/Realm.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Steamworks
|
||||||
|
{
|
||||||
|
public static class Realm
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// true = serverside
|
||||||
|
//
|
||||||
|
static Stack<bool> _stack = new Stack<bool>();
|
||||||
|
|
||||||
|
public static bool IsServer => _stack.Count > 0 && _stack.Peek();
|
||||||
|
|
||||||
|
public static bool IsClient => _stack.Count == 0 || !_stack.Peek();
|
||||||
|
|
||||||
|
|
||||||
|
static public IDisposable Server()
|
||||||
|
{
|
||||||
|
_stack.Push( true );
|
||||||
|
return new StackPopper();
|
||||||
|
}
|
||||||
|
|
||||||
|
static public IDisposable Client()
|
||||||
|
{
|
||||||
|
_stack.Push( false );
|
||||||
|
return new StackPopper();
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct StackPopper : IDisposable
|
||||||
|
{
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_stack.Pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user