mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-08-30 02:49:32 +00:00
Do not receive messages in onMessage is not set
This commit is contained in:
@ -60,15 +60,17 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
void operator()(P... args) {
|
||||
void operator()(P... args) const {
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex);
|
||||
if (callback)
|
||||
callback(args...);
|
||||
}
|
||||
|
||||
operator bool() const { return callback ? true : false; }
|
||||
|
||||
private:
|
||||
std::function<void(P...)> callback;
|
||||
std::recursive_mutex mutex;
|
||||
mutable std::recursive_mutex mutex;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ void Channel::triggerAvailable(size_t available) {
|
||||
if (available == 1)
|
||||
mAvailableCallback();
|
||||
|
||||
while (available--) {
|
||||
while (mMessageCallback && available--) {
|
||||
auto message = receive();
|
||||
if (!message)
|
||||
break;
|
||||
|
Reference in New Issue
Block a user