示例#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);
        }
示例#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();
        }
示例#3
0
        internal void AddPacket(RconPacket packet)
        {
            _packets.Enqueue(packet);

            Complete = true;
        }