示例#1
0
 /// <summary>
 ///   Initializes a new instance of <see cref="DatagramDispatcher" />
 ///   and establishes the <see cref="UdpClient" /> to be used.
 /// </summary>
 /// <param name="client"> The <see cref="RConClient" /> to be used to connect to the RCon server. </param>
 internal DatagramDispatcher(RConClient client)
 {
     this.Metrics = client.Metrics;
     this.DiscardConsoleMessages = client.DiscardConsoleMessages;
     this.KeepAlivePeriod = TimeSpan.FromSeconds(25);
     // throw new ArgumentException("Test shall not pass.");
     this.ConMsgsTracker = new SequenceTracker();
     this.CmdsTracker = new SequenceTracker();
     this.rconClient = client;
     this.UdpClient = client.UdpClient;
     this.ResponseDispatcher = new ResponseDispatcher();
     this.datagramSender = new DatagramSender(this);
     this.Log = LogManager.GetLogger(this.GetType());
     this.Start();
 }
示例#2
0
        internal KeepAliveTracker(DatagramSender datagramSender, RConMetrics metrics, ILog log)
        {
            if (datagramSender == null)
            {
                throw new ArgumentNullException("datagramSender");
            }
            if (metrics == null)
            {
                throw new ArgumentNullException("metrics");
            }
            if (log == null)
            {
                throw new ArgumentNullException("log");
            }

            this.Log = log;
            this.MaxTries = 5;
            this.datagramSender = datagramSender;
            this.metrics = metrics;
        }
示例#3
0
        /// <summary>
        ///   Creates a new instance of this class.
        /// </summary>
        /// <param name="buffer"> The received bytes. </param>
        /// <param name="dgramSender"> The <see cref="DatagramSender"/> to use to send datagrams to the server. </param>
        /// <param name="log"> The <see cref="ILog"/> instance to be used to log tracing messages. </param>
        internal InboundProcessor(byte[] buffer, DatagramSender dgramSender, ILog log)
        {
            if (dgramSender == null)
            {
                throw new ArgumentNullException("dgramSender");
            }
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }
            if (log == null)
            {
                throw new ArgumentNullException("log");
            }

            this.dgramSender = dgramSender;
            this.buffer = buffer;
            this.log = log;

            if (this.buffer.Length > Constants.DatagramTypeIndex)
            {
                this.type = (DatagramType)Buffer.GetByte(this.buffer, Constants.DatagramTypeIndex);
            }
        }