Beispiel #1
0
        /// <summary>
        /// Respond Command to manager.
        /// </summary>
        /// <param name="command">Command to respond.</param>
        public virtual void RespondCommand(Command command)
        {
            if (!IsSettingsValid)
            {
                return;
            }

            var commandBytes = CommandParser.ToBuffer(command);

            CommandIO.WriteBuffer(commandBytes);
        }
Beispiel #2
0
        /// <summary>
        /// Dequeue Commands from pending buffer.
        /// </summary>
        /// <returns>Current Commands.</returns>
        public virtual IEnumerable <Command> DequeueCommands()
        {
            if (!IsSettingsValid)
            {
                return(null);
            }

            var commandBytes = CommandIO.ReadBuffer();
            var ioCommands   = CommandParser.ToCommands(commandBytes);

            if (ioCommands != null)
            {
                commandBuffer.AddRange(ioCommands);
            }

            var currentCommands = new List <Command>(commandBuffer);

            commandBuffer.Clear();
            return(currentCommands);
        }
        /// <summary>
        /// Dequeue commands from pending and IO buffer.
        /// </summary>
        /// <returns>Current commands.</returns>
        public virtual IEnumerable <Command> DequeueCommands()
        {
            if (!IsSettingsValid)
            {
                return(null);
            }

            var ioBuffer   = CommandIO.ReadBuffer();
            var ioCommands = CommandParser.ToCommands(ioBuffer);

            if (ioCommands != null)
            {
                commandBuffer.AddRange(ioCommands);
            }

            var commands = commandBuffer.ToArray();

            commandBuffer.Clear();
            return(commands);
        }