Commit c47b7cb7 authored by Christoph Conrads's avatar Christoph Conrads Committed by ChristophConrads-deepstreamHub

Events: listener signature more similar to JS API

parent 2569ca8b
......@@ -56,7 +56,7 @@ namespace deepstream
* The following alias is the signature of a deepstream event listener
* callback.
*/
typedef std::function<bool(const Name&, bool, const Name&)> ListenFn;
typedef std::function<bool(const Name&, bool)> ListenFn;
/**
* The representation of a callback is stored as a smart pointer.
*/
......
......@@ -303,7 +303,7 @@ void Event::notify_listeners_(const Message& message)
// listener may decide to unlisten.
ListenFnPtr p_f = it->second;
auto f = *p_f;
bool accept = f(pattern, is_subscribed, match);
bool accept = f(match, is_subscribed);
if( message.action() == Action::SUBSCRIPTION_FOR_PATTERN_REMOVED )
......
......@@ -144,7 +144,7 @@ BOOST_AUTO_TEST_CASE(simple)
BOOST_CHECK( event.listener_map_.empty() );
Event::ListenFn g = [] (const Name&, bool, const Name&) { return true; };
Event::ListenFn g = [] (const Name&, bool) { return true; };
Event::ListenFnPtr q1( new Event::ListenFn(g) );
Event::ListenFnPtr q2( new Event::ListenFn(g) );
......@@ -398,14 +398,7 @@ BOOST_AUTO_TEST_CASE(listener_notification)
bool has_subscriber = false;
Event::ListenFn f =
[pattern, match, &has_subscriber]
(const Name& my_pattern, bool b, const Name& my_match) {
BOOST_REQUIRE_EQUAL( pattern.size(), my_pattern.size() );
BOOST_CHECK(
std::equal(pattern.cbegin(), pattern.cend(), my_pattern.cbegin()
)
);
[match, &has_subscriber] (const Name& my_match, bool b) {
BOOST_REQUIRE_EQUAL( match.size(), my_match.size() );
BOOST_CHECK(
std::equal(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment