Пример #1
0
        /// <summary>
        ///   Acknowledges, checks for repeated sequence numbers, and signals to
        ///   skip further processing when <paramref name="discardConsoleMessages"/> is true.
        /// </summary>
        /// <param name="discardConsoleMessages"> Whether to signal to skip further processing. </param>
        /// <param name="consoleMessagesTracker"> The <see cref="SequenceTracker"/> used to keep track of sequence numbers. </param>
        /// <returns> True if no further processing should be done; false otherwise. </returns>
        private bool PreProcessConsoleMessage(bool discardConsoleMessages, SequenceTracker consoleMessagesTracker)
        {
            byte conMsgSeq = Buffer.GetByte(this.buffer, Constants.ConsoleMessageSequenceNumberIndex);
            this.log.TraceFormat("M#{0:000} Received", conMsgSeq);

            this.dgramSender.AcknowledgeMessage(conMsgSeq);
            if (discardConsoleMessages)
            {
                return true;
            }

            // if we already received a console message with this seq number
            bool repeated = consoleMessagesTracker.Contains(conMsgSeq);
            if (repeated)
            {
                // if we did, just acknowledge it and don't process it
                // (the server probably didn't receive our previous ack)
                return true;
            }

            // register the sequence number and continue processing the message
            consoleMessagesTracker.StartTracking(conMsgSeq);
            return false;
        }
Пример #2
0
        /// <summary>
        ///   Checks for repeated command responses.
        /// </summary>
        /// <param name="commandsTracker"> The <see cref="SequenceTracker"/> used to keep track of sequence numbers. </param>
        /// <returns> True if no further processing should be done; false otherwise. </returns>
        private bool PreProcessCommandResponse(SequenceTracker commandsTracker)
        {
            byte cmdSeq = Buffer.GetByte(this.buffer, Constants.CommandResponseSequenceNumberIndex);
            bool repeated = commandsTracker.Contains(cmdSeq);
            if (repeated)
            {
                // doesn't repeat because multipart?
                if (Buffer.GetByte(this.buffer, Constants.CommandResponseMultipartMarkerIndex) != 0x00)
                {
                    return true;
                } // else go ahead and dispatch the part
            }
            else
            {
                commandsTracker.StartTracking(cmdSeq);
            }

            return false;
        }