/// <summary> /// Processes the received message. /// </summary> /// <param name="message">The message.</param> private void ProcessRecievedMessage(RequestMessage message) { message.CannotBeNull(); if (this.HandshakeState == HandshakeState.SendAndReceived) { if (message.PieceIndex >= 0 && message.PieceIndex < this.pieceManager.BlockCount && message.BlockOffset >= 0 && message.BlockOffset < this.pieceManager.GetBlockCount(message.PieceIndex) && message.BlockOffset / this.pieceManager.BlockLength == 0 && message.BlockLength == this.pieceManager.GetBlockLength(message.PieceIndex, message.BlockOffset / this.pieceManager.BlockLength)) { this.EnqueueUploadMessage(message); } else { this.OnCommunicationErrorOccurred(this, new PeerCommunicationErrorEventArgs("Invalid request message.", false)); } } else { this.OnCommunicationErrorOccurred(this, new PeerCommunicationErrorEventArgs("Invalid message sequence.", true)); } }