Fixed max message size getter

This commit is contained in:
Paul-Louis Ageneau
2020-03-22 14:31:51 +01:00
parent ffa9a15173
commit d4c5ef8155

View File

@ -154,13 +154,13 @@ bool DataChannel::isOpen(void) const { return mIsOpen; }
bool DataChannel::isClosed(void) const { return mIsClosed; }
size_t DataChannel::maxMessageSize() const {
size_t max = DEFAULT_MAX_MESSAGE_SIZE;
size_t remoteMax = DEFAULT_MAX_MESSAGE_SIZE;
if (auto pc = mPeerConnection.lock())
if (auto description = pc->remoteDescription())
if (auto maxMessageSize = description->maxMessageSize())
return *maxMessageSize > 0 ? *maxMessageSize : LOCAL_MAX_MESSAGE_SIZE;
remoteMax = *maxMessageSize > 0 ? *maxMessageSize : LOCAL_MAX_MESSAGE_SIZE;
return std::min(max, LOCAL_MAX_MESSAGE_SIZE);
return std::min(remoteMax, LOCAL_MAX_MESSAGE_SIZE);
}
size_t DataChannel::availableAmount() const { return mRecvQueue.amount(); }