Skip to content

Commit 8558d0a

Browse files
committed
osc: added methods for removing all listeners and getting all listeners.
1 parent 4a597c3 commit 8558d0a

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

blocks/OSC/src/cinder/osc/Osc.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,18 @@ void ReceiverBase::removeListener( const std::string &address )
11411141
mListeners.erase( foundListener );
11421142
}
11431143

1144+
void ReceiverBase::removeAllListeners()
1145+
{
1146+
std::lock_guard<std::mutex> lock( mListenerMutex );
1147+
mListeners.clear();
1148+
}
1149+
1150+
ReceiverBase::Listeners ReceiverBase::getListeners() const
1151+
{
1152+
std::lock_guard<std::mutex> lock( mListenerMutex );
1153+
return mListeners;
1154+
}
1155+
11441156
void ReceiverBase::dispatchMethods( uint8_t *data, uint32_t size, const asio::ip::address &senderIpAddress, uint16_t senderPort )
11451157
{
11461158
std::vector<Message> messages;

blocks/OSC/src/cinder/osc/Osc.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,11 @@ class ReceiverBase {
651651
void setListener( const std::string &address, ListenerFn listener );
652652
//! Removes the listener associated with \a address.
653653
void removeListener( const std::string &address );
654-
654+
//! Removes all listeners
655+
void removeAllListeners();
656+
//! Returns all listeners by value
657+
Listeners getListeners() const;
658+
655659
protected:
656660
ReceiverBase() = default;
657661
//! Non-copyable.
@@ -680,7 +684,7 @@ class ReceiverBase {
680684
virtual void closeImpl() = 0;
681685

682686
Listeners mListeners;
683-
std::mutex mListenerMutex;
687+
mutable std::mutex mListenerMutex;
684688
std::set<std::string> mDisregardedAddresses;
685689
};
686690

0 commit comments

Comments
 (0)