Example #1
0
        /// <summary>
        /// Checks if this message is the only or final message in response to a request.
        /// </summary>
        /// <param name="header">The message header.</param>
        /// <param name="version">The ETP version.</param>
        /// <returns><c>true</c> if this is an acknowledge message with NoData set,
        /// a protocol exception, or a different message type that is either the final
        /// part of a multi-part message or not part of a multi-part message;
        /// <c>false</c> otherwise.</returns>
        public static bool IsFinalResponse(this IMessageHeader header, EtpVersion version)
        {
            if (!header.HasCorrelationId())
            {
                return(false);
            }

            if (version == EtpVersion.v11)
            {
                if (header.IsAcknowledge() && header.IsNoData())
                {
                    return(true);
                }

                if (header.IsProtocolException())
                {
                    return(true);
                }

                return(!header.IsMultiPart() || header.IsFinalPart());
            }
            else
            {
                return(header.IsFinalPart());
            }
        }
Example #2
0
        /// <summary>
        /// Determines whether the message body and optional header extension can be compressed based on the specified header.
        /// </summary>
        /// <param name="header">The header.</param>
        /// <returns><c>true</c> if the message body and optional header extension can be comressed; otherwise, <c>false</c>.</returns>
        public static bool CanBeCompressed(this IMessageHeader header)
        {
            // Never compress RequestSession or OpenSession in Core protocol
            if (header.Protocol == 0 && (header.IsRequestSession() || header.IsOpenSession()))
            {
                return(false);
            }

            // Don't compress Acknowledge or ProtocolException when sent by any protocol
            if (header.IsAcknowledge() || header.IsProtocolException())
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Determines whether the message body can be compressed based on the specified header.
        /// </summary>
        /// <param name="header">The header.</param>
        /// <param name="checkMessageFlags">A flag to check the message flags provided in the header.</param>
        /// <returns><c>true</c> if the message body can be comressed; otherwise, <c>false</c>.</returns>
        public static bool CanCompressMessageBody(this IMessageHeader header, bool checkMessageFlags = false)
        {
            // Never compress RequestSession or OpenSession in Core protocol
            if (header.Protocol == 0 && (header.IsRequestSession() || header.IsOpenSession()))
            {
                return(false);
            }

            // Don't compress Acknowledge or ProtocolException when sent by any protocol
            if (header.IsAcknowledge() || header.IsProtocolException())
            {
                return(false);
            }

            // Do the message flags indicate the body was compressed
            return(!checkMessageFlags || header.HasFlag(MessageFlags.Compressed));
        }
Example #4
0
 /// <summary>
 /// Checks if this header is from an open session message.
 /// </summary>
 /// <param name="header">The message header.</param>
 /// <returns><c>true</c> if the header is from an open session message; <c>false</c> otherwise.</returns>
 public static bool IsAllowedBeforeSessionIsOpen(this IMessageHeader header)
 {
     return(header.IsRequestSession() || header.IsOpenSession() || header.IsAcknowledge() || header.IsProtocolException() || header.IsCloseSession());
 }