using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; namespace QueryMaster { /// /// Provides methods to create Server instance /// public static class ServerQuery { /// /// Returns an object that represents the server /// /// Base engine which game uses /// IP-Address of server /// Port number of server /// Obsolete Gold Source servers reply only to half life protocol.if set to true then it would use half life protocol.If set to null,then protocol is identified at runtime[Default : false] /// Sets Socket's SendTimeout Property. /// Sets Socket's ReceiveTimeout. /// Instance of server class that represents the connected server. public static Server GetServerInstance(EngineType type, string ip, ushort port, bool? isObsolete = false, int sendTimeOut = 3000, int receiveTimeOut = 3000) { IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse(ip), (int)port); return GetServerInstance(type, endPoint, isObsolete, sendTimeOut, receiveTimeOut); } /// /// Returns an object that represents the server /// /// Base engine which game uses /// Socket address of server /// Obsolete Gold Source servers reply only to half life protocol.if set to true then it would use half life protocol.If set to null,then protocol is identified at runtime. /// Sets Socket's SendTimeout Property. /// Sets Socket's ReceiveTimeout. /// Instance of server class that represents the connected server public static Server GetServerInstance(EngineType type, IPEndPoint endPoint, bool? isObsolete = false, int sendTimeOut = 3000, int receiveTimeOut = 3000) { Server server = null; switch (type) { case EngineType.GoldSource: server = new GoldSource(endPoint, isObsolete, sendTimeOut, receiveTimeOut); break; case EngineType.Source: server = new Source(endPoint, sendTimeOut, receiveTimeOut); break; default: throw new ArgumentException("An invalid EngineType was specified."); } return server; } /// /// Returns an object that represents the server /// /// Name of game /// Socket address of server /// Obsolete Gold Source servers reply only to half life protocol.if set to true then it would use half life protocol.If set to null,then protocol is identified at runtime. /// Sets Socket's SendTimeout Property. /// Sets Socket's ReceiveTimeout. /// Instance of server class that represents the connected server public static Server GetServerInstance(Game game, IPEndPoint endPoint, bool? isObsolete = false, int sendTimeOut = 3000, int receiveTimeOut = 3000) { if ((int)game <= 130) return GetServerInstance(EngineType.GoldSource, endPoint, isObsolete, sendTimeOut, receiveTimeOut); else return GetServerInstance(EngineType.Source, endPoint, isObsolete, sendTimeOut, receiveTimeOut); } /// /// Returns an object that represents the server /// /// Name of game /// IP-Address of server /// Port number of server /// Obsolete Gold Source servers reply only to half life protocol.if set to true then it would use half life protocol.If set to null,then protocol is identified at runtime. /// Sets Socket's SendTimeout Property. /// Sets Socket's ReceiveTimeout. /// Instance of server class that represents the connected server public static Server GetServerInstance(Game game, string ip, ushort port, bool? isObsolete = false, int sendTimeOut = 3000, int receiveTimeOut = 3000) { IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse(ip), (int)port); if ((int)game <= 130) return GetServerInstance(EngineType.GoldSource, endPoint, isObsolete, sendTimeOut, receiveTimeOut); else return GetServerInstance(EngineType.Source, endPoint, isObsolete, sendTimeOut, receiveTimeOut); } } }