Пример #1
0
 /// <summary>
 /// Returns an object that represents the server
 /// </summary>
 /// <param name="type">Base engine which game uses</param>
 /// <param name="endPoint">Socket address of server</param>
 /// <param name="isObsolete">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.</param>
 /// <param name="sendTimeOut">Sets Socket's SendTimeout Property.</param>
 /// <param name="receiveTimeOut">Sets Socket's ReceiveTimeout.</param>
 /// <returns>Instance of server class that represents the connected server</returns>
 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;
 }
Пример #2
0
        /// <summary>
        /// Returns an object that represents the server
        /// </summary>
        /// <param name="type">Base engine which game uses</param>
        /// <param name="endPoint">Socket address of server</param>
        /// <param name="isObsolete">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.</param>
        /// <param name="sendTimeOut">Sets Socket's SendTimeout Property.</param>
        /// <param name="receiveTimeOut">Sets Socket's ReceiveTimeout.</param>
        /// <returns>Instance of server class that represents the connected server</returns>
        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);
        }