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