This commit is contained in:
Garry Newman 2016-11-03 14:05:50 +00:00
parent 2fef034547
commit 84e38601d6
4 changed files with 57 additions and 52 deletions

View File

@ -25,6 +25,10 @@ namespace Facepunch.Steamworks
internal override bool IsGameServer { get { return true; } } internal override bool IsGameServer { get { return true; } }
public ServerQuery Query;
public ServerStats Stats;
public ServerAuth Auth;
/// <summary> /// <summary>
/// Initialize a Steam Server instance /// Initialize a Steam Server instance
/// </summary> /// </summary>
@ -66,6 +70,13 @@ namespace Facepunch.Steamworks
BotCount = 0; BotCount = 0;
MapName = "unset"; MapName = "unset";
//
// Child classes
//
Query = new ServerQuery( this );
Stats = new ServerStats( this );
Auth = new ServerAuth( this );
// //
// Run update, first call does some initialization // Run update, first call does some initialization
// //
@ -238,5 +249,25 @@ namespace Facepunch.Steamworks
{ {
get { return native.gameServer.BLoggedOn(); } get { return native.gameServer.BLoggedOn(); }
} }
public override void Dispose()
{
if ( Query != null )
{
Query = null;
}
if ( Stats != null )
{
Stats = null;
}
if ( Auth != null )
{
Auth = null;
}
base.Dispose();
}
} }
} }

View File

@ -5,22 +5,6 @@ using System.Text;
namespace Facepunch.Steamworks namespace Facepunch.Steamworks
{ {
public partial class Server
{
ServerAuth _auth;
public ServerAuth Auth
{
get
{
if ( _auth == null )
_auth = new ServerAuth( this );
return _auth;
}
}
}
public class ServerAuth public class ServerAuth
{ {
internal Server server; internal Server server;

View File

@ -6,22 +6,9 @@ using System.Text;
namespace Facepunch.Steamworks namespace Facepunch.Steamworks
{ {
public partial class Server /// <summary>
{ /// If you're manually processing the server queries, you should use this class.
ServerQuery _query; /// </summary>
public ServerQuery Query
{
get
{
if ( _query == null )
_query = new ServerQuery( this );
return _query;
}
}
}
public class ServerQuery public class ServerQuery
{ {
internal Server server; internal Server server;
@ -32,20 +19,39 @@ namespace Facepunch.Steamworks
server = s; server = s;
} }
/// <summary>
/// A server query packet.
/// </summary>
public struct Packet public struct Packet
{ {
/// <summary>
/// Target IP address
/// </summary>
public uint Address { get; internal set; } public uint Address { get; internal set; }
public byte[] Data { get; internal set; }
/// <summary>
/// Target port
/// </summary>
public ushort Port { get; internal set; } public ushort Port { get; internal set; }
/// <summary>
/// This data is pooled. Make a copy if you don't use it immediately.
/// This buffer is also quite large - so pay attention to Size.
/// </summary>
public byte[] Data { get; internal set; }
/// <summary>
/// Size of the data
/// </summary>
public int Size { get; internal set; } public int Size { get; internal set; }
} }
/// <summary> /// <summary>
/// If true, Steam wants to send a packet. You should respond by sending /// If true, Steam wants to send a packet. You should respond by sending
/// this packet in an unconnected way to the returned Address and Port /// this packet in an unconnected way to the returned Address and Port.
/// </summary> /// </summary>
/// <param name="packet"></param> /// <param name="packet">Packet to send. The Data passed is pooled - so use it immediately.</param>
/// <returns></returns> /// <returns>True if we want to send a packet</returns>
public unsafe bool GetOutgoingPacket( out Packet packet ) public unsafe bool GetOutgoingPacket( out Packet packet )
{ {
packet = new Packet(); packet = new Packet();

View File

@ -6,22 +6,6 @@ using System.Text;
namespace Facepunch.Steamworks namespace Facepunch.Steamworks
{ {
public partial class Server
{
ServerStats _stats;
public ServerStats Stats
{
get
{
if ( _stats == null )
_stats = new ServerStats( this );
return _stats;
}
}
}
/// <summary> /// <summary>
/// Allows getting and setting stats on users from the gameserver. These stats /// Allows getting and setting stats on users from the gameserver. These stats
/// should have been set up on the Steamworks website for your app. /// should have been set up on the Steamworks website for your app.