Fix WebRTCDataChannels crash

This commit is contained in:
David Rowe 2021-09-03 19:04:24 +12:00
parent 65dec6dfd8
commit ff72b422b3

View file

@ -524,8 +524,14 @@ bool WebRTCDataChannels::sendDataMessage(int dataChannelID, const QByteArray& by
/// @brief Gets the number of bytes waiting to be written on a data channel.
/// @param port The data channel ID.
/// @return The number of bytes waiting to be written on the data channel.
/// @return The number of bytes waiting to be written on the data channel; 0 if the channel doesn't exist.
qint64 WebRTCDataChannels::getBufferedAmount(int dataChannelID) const {
if (!_connectionsByDataChannel.contains(dataChannelID)) {
#ifdef WEBRTC_DEBUG
qCDebug(networking_webrtc) << "WebRTCDataChannels::getBufferedAmount() : Channel doesn't exist:" << dataChannelID;
#endif
return 0;
}
auto connection = _connectionsByDataChannel.value(dataChannelID);
return connection->getBufferedAmount();
}