From 84e38601d684f42f9a812afa240baf2116575beb Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Thu, 3 Nov 2016 14:05:50 +0000 Subject: [PATCH] Cleanup --- Facepunch.Steamworks/Server.cs | 31 +++++++++++++++++++ Facepunch.Steamworks/Server/Auth.cs | 16 ---------- Facepunch.Steamworks/Server/Query.cs | 46 ++++++++++++++++------------ Facepunch.Steamworks/Server/Stats.cs | 16 ---------- 4 files changed, 57 insertions(+), 52 deletions(-) diff --git a/Facepunch.Steamworks/Server.cs b/Facepunch.Steamworks/Server.cs index 1d94652..1dc7069 100644 --- a/Facepunch.Steamworks/Server.cs +++ b/Facepunch.Steamworks/Server.cs @@ -25,6 +25,10 @@ namespace Facepunch.Steamworks internal override bool IsGameServer { get { return true; } } + public ServerQuery Query; + public ServerStats Stats; + public ServerAuth Auth; + /// /// Initialize a Steam Server instance /// @@ -66,6 +70,13 @@ namespace Facepunch.Steamworks BotCount = 0; MapName = "unset"; + // + // Child classes + // + Query = new ServerQuery( this ); + Stats = new ServerStats( this ); + Auth = new ServerAuth( this ); + // // Run update, first call does some initialization // @@ -238,5 +249,25 @@ namespace Facepunch.Steamworks { 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(); + } } } diff --git a/Facepunch.Steamworks/Server/Auth.cs b/Facepunch.Steamworks/Server/Auth.cs index 5d290e1..24ded75 100644 --- a/Facepunch.Steamworks/Server/Auth.cs +++ b/Facepunch.Steamworks/Server/Auth.cs @@ -5,22 +5,6 @@ using System.Text; 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 { internal Server server; diff --git a/Facepunch.Steamworks/Server/Query.cs b/Facepunch.Steamworks/Server/Query.cs index 4c74e31..67b014f 100644 --- a/Facepunch.Steamworks/Server/Query.cs +++ b/Facepunch.Steamworks/Server/Query.cs @@ -6,22 +6,9 @@ using System.Text; namespace Facepunch.Steamworks { - public partial class Server - { - ServerQuery _query; - - public ServerQuery Query - { - get - { - if ( _query == null ) - _query = new ServerQuery( this ); - - return _query; - } - } - } - + /// + /// If you're manually processing the server queries, you should use this class. + /// public class ServerQuery { internal Server server; @@ -32,20 +19,39 @@ namespace Facepunch.Steamworks server = s; } + /// + /// A server query packet. + /// public struct Packet { + /// + /// Target IP address + /// public uint Address { get; internal set; } - public byte[] Data { get; internal set; } + + /// + /// Target port + /// public ushort Port { get; internal set; } + + /// + /// 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. + /// + public byte[] Data { get; internal set; } + + /// + /// Size of the data + /// public int Size { get; internal set; } } /// /// 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. /// - /// - /// + /// Packet to send. The Data passed is pooled - so use it immediately. + /// True if we want to send a packet public unsafe bool GetOutgoingPacket( out Packet packet ) { packet = new Packet(); diff --git a/Facepunch.Steamworks/Server/Stats.cs b/Facepunch.Steamworks/Server/Stats.cs index 72c80f0..3234f76 100644 --- a/Facepunch.Steamworks/Server/Stats.cs +++ b/Facepunch.Steamworks/Server/Stats.cs @@ -6,22 +6,6 @@ using System.Text; namespace Facepunch.Steamworks { - public partial class Server - { - ServerStats _stats; - - public ServerStats Stats - { - get - { - if ( _stats == null ) - _stats = new ServerStats( this ); - - return _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.