Esempio n. 1
0
        /// <inheritdoc/>
        public int Write(IRconCommand command)
        {
            int id = 0;

            currentId++;

            id = currentId;

            _responses.TryAdd(id, new RconResponse(id));

            var packet     = RconPacket.From(id, command);
            var terminator = RconPacket.CommandTerminator(id);

            _writer.Write(packet.GetBytes());
            _writer.Flush();

            return(id);
        }
Esempio n. 2
0
        private void CheckForData()
        {
            while (!_stopEvent.WaitOne(1))
            {
                try
                {
                    if (!_rconStream.DataAvailable)
                    {
                        continue;
                    }

                    var packet = RconPacket.From(_reader);

                    _responses[packet.CommandId].AddPacket(packet);
                }
                catch
                {
                    continue;
                }
            }

            _stoppedEvent.Set();
        }
Esempio n. 3
0
        internal void AddPacket(RconPacket packet)
        {
            _packets.Enqueue(packet);

            Complete = true;
        }