public bool TryAddMessagePart(MessagePart messagePart, int mtuSize) { byte[] bytes = messagePart.Encode(); if (bytes.Length + _currentSize > mtuSize) { return(false); } if (messagePart.ReliabilityHeader.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.ReliabilityHeader.PartCount > 0 && messagePart.ReliabilityHeader.PartIndex > 0) { Header.IsContinuousSend = true; } if (FirstMessageId == 0) { FirstMessageId = messagePart.ContainedMessageId; } MessageParts.Add(messagePart); _currentSize = _currentSize + bytes.Length; return(true); }
public bool TryAddMessagePart(MessagePart messagePart, int mtuSize) { byte[] bytes = messagePart.Encode(); if (_currentSize + bytes.Length > (mtuSize - RakOfflineHandler.UdpHeaderSize)) { return(false); } if (messagePart.ReliabilityHeader.PartCount > 0 && messagePart.ReliabilityHeader.PartIndex > 0) { Header.IsContinuousSend = true; } //TODO: Get rid of this stuff. if (FirstMessageId == 0) { FirstMessageId = messagePart.ContainedMessageId; } MessageParts.Add(messagePart); _currentSize += bytes.Length; return(true); }