Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
deepstream.io-client-cpp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Christoph Conrads
deepstream.io-client-cpp
Commits
c47b7cb7
Commit
c47b7cb7
authored
Feb 10, 2017
by
Christoph Conrads
Committed by
ChristophConrads-deepstreamHub
Feb 10, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Events: listener signature more similar to JS API
parent
2569ca8b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
11 deletions
+4
-11
event.hpp
include/deepstream/event.hpp
+1
-1
event.cpp
src/event.cpp
+1
-1
event.cpp
test/event.cpp
+2
-9
No files found.
include/deepstream/event.hpp
View file @
c47b7cb7
...
...
@@ -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.
*/
...
...
src/event.cpp
View file @
c47b7cb7
...
...
@@ -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
)
...
...
test/event.cpp
View file @
c47b7cb7
...
...
@@ -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
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment