Exemplo n.º 1
0
        public bool TryAddMessagePart(MessagePart messagePart, int mtuSize)
        {
            var bytes = messagePart.Encode();

            if (bytes.Length + _currentSize > mtuSize)
            {
                return(false);
            }
            if (messagePart.Header.HasSplit && MessageParts.Count > 0)
            {
                return(false);
            }
            //if (Header.isContinuousSend) return false;

            if (messagePart.Header.PartCount > 0 && messagePart.Header.PartIndex > 0)
            {
                Header.isContinuousSend = true;
            }

            if (FirstMessageId == 0)
            {
                FirstMessageId = messagePart.ContainedMessageId;
            }

            MessageParts.Add(messagePart);
            _currentSize = _currentSize + bytes.Length;

            return(true);
        }
Exemplo n.º 2
0
        public bool TryAddMessagePart(MessagePart messagePart, int mtuSize)
        {
            var bytes = messagePart.Encode();

            if (bytes.Length + _currentSize > mtuSize)
            {
                return(false);
            }
            if (messagePart.Header.HasSplit && MessageParts.Count > 0)
            {
                //Log.Warn(string.Format("Message has split and count > 0: {0}, MTU: {1}", MessageParts.Count, mtuSize));
                return(false);
            }
            //if (Header.isContinuousSend) return false;

            if (messagePart.Header.PartCount > 0 && messagePart.Header.PartIndex > 0)
            {
                Header.isContinuousSend = true;
            }

            if (FirstMessageId == 0)
            {
                FirstMessageId = messagePart.ContainedMessageId;
            }

            MessageParts.Add(messagePart);
            _currentSize = _currentSize + bytes.Length;

            return(true);
        }
Exemplo n.º 3
0
        public bool TryAddMessagePart(MessagePart messagePart, int mtuSize)
        {
            var bytes = messagePart.Encode();

            if (bytes.Length + _currentSize > mtuSize)
            {
                return(false);
            }
            if (messagePart.Header.HasSplit && MessageParts.Count > 0)
            {
                if (Log.IsDebugEnabled)
                {
                    Log.Warn($"Message has split and count > 0: {MessageParts.Count}, MTU: {mtuSize}");
                }
                return(false);
            }
            //if (Header.isContinuousSend) return false;

            if (messagePart.Header.PartCount > 0 && messagePart.Header.PartIndex > 0)
            {
                Header.isContinuousSend = true;
            }

            if (FirstMessageId == 0)
            {
                FirstMessageId = messagePart.ContainedMessageId;
            }

            MessageParts.Add(messagePart);
            _currentSize = _currentSize + bytes.Length;

            return(true);
        }