Esempio n. 1
0
        /// <summary>
        /// Transfers registered messages to the message container.
        /// </summary>
        /// <param name="messageContainer">The Message Containter.</param>
        public void MoveMessages(MessageContainer messageContainer)
        {
            lock (this)
            {
                for (int i = 0; i < this._messages.Length; i++)
                {
                    Message message = this._messages[i] as Message;

                    // 2.5.1 ignores messages that have been answered
                    if (message != null && !message.HasBeenAsnwered)
                    {
                        message.SerializedContent.Position = 0;
                        messageContainer.AddMessage(message, false);
                        this._messages[i] = null;
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Fills in the provided stream with the specified messages that the total size as close to the recommended size as possible.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="messageContainer">Accumulated messages or a null reference.</param>
        /// <param name="packedMessages">This instance will contain all packed messages after this function completes.</param>
        /// <param name="resultContent">The filled stream.</param>
        /// <param name="intermediateBuffer">The intermediate buffer.</param>
        /// <param name="recommendedSize">The recommended size.</param>
        public static void FillInLabelledStream(Message message, MessageContainer messageContainer, ArrayList packedMessages, GenuineChunkedStream resultContent, byte[] intermediateBuffer, int recommendedSize)
        {
            BinaryWriter binaryWriter = new BinaryWriter(resultContent);

            if (packedMessages != null)
            {
                packedMessages.Clear();
            }

            while (message != null)
            {
                // not finished yet
                binaryWriter.Write((byte)0);

                if (packedMessages != null)
                {
                    packedMessages.Add(message);
                }

                MessageCoder.WriteLabelledStream(message.SerializedContent, resultContent, binaryWriter, intermediateBuffer);
                message = null;

                if (resultContent.Length > recommendedSize)
                {
                    break;
                }

                if (messageContainer != null)
                {
                    message = messageContainer.GetMessage();
                }

                if (message == null)
                {
                    break;
                }
            }

            // "finish" flag
            binaryWriter.Write((byte)1);
        }