Example #1
0
        /// <summary>
        /// Determines whether the message can have an optional header extension.
        /// </summary>
        /// <param name="header">The header.</param>
        /// <returns><c>true</c> if the message can have an optional header extension; otherwise, <c>false</c>.</returns>
        public static bool CanHaveHeaderExtension(this IMessageHeader header)
        {
            // Never compress RequestSession or OpenSession in Core protocol
            if (header.Protocol == 0 && (header.IsRequestSession() || header.IsOpenSession()))
            {
                return(false);
            }

            return(true);
        }
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());
 }