Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
oberstet committed Apr 15, 2017
1 parent 6cad8f2 commit a4556aa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 42 deletions.
41 changes: 8 additions & 33 deletions test/test_pubsub_multiple_matching_subs.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ exports.testPubsubMultipleMatchingSubs = function (testcase) {

var received = 0;

function shutdown () {
function on_event (args, kwargs, details, sub) {
test.log('event: args=', args, ', kwargs=', kwargs);
test.log('subscription: sub_topic=', sub.topic, ', sub_match=', sub.options.match, ', session_ident=', sub.session._ident);
received += 1;
if (received >= 9) {
test.log("closing ..");

Expand All @@ -94,40 +97,12 @@ exports.testPubsubMultipleMatchingSubs = function (testcase) {
}
}

function on_event_b (args, kwargs, details, sub) {
test.log('event_b: args=', args, ', kwargs=', kwargs);
test.log('subscription: sub_topic=', sub.topic, ', sub_match=', sub.options.match, ', session_ident=', sub.session._ident);
received += 1;
shutdown();
}

function on_event_c (args, kwargs, details, sub) {
test.log('event_c: args=', args, ', kwargs=', kwargs);
test.log('subscription: sub_topic=', sub.topic, ', sub_match=', sub.options.match, ', session_ident=', sub.session._ident);
received += 1;
shutdown();
}

function on_event_d (args, kwargs, details, sub) {
test.log('event_d: args=', args, ', kwargs=', kwargs);
test.log('subscription: sub_topic=', sub.topic, ', sub_match=', sub.options.match, ', session_ident=', sub.session._ident);
received += 1;
shutdown();
}

function on_event_e (args, kwargs, details, sub) {
test.log('event_e: args=', args, ', kwargs=', kwargs);
test.log('subscription: sub_topic=', sub.topic, ', sub_match=', sub.options.match, ', session_ident=', sub.session._ident);
received += 1;
shutdown();
}

var dl2 = [];

dl2.push(session_b.subscribe('com..topic1', on_event_b, {match: 'wildcard'}));
dl2.push(session_c.subscribe('com.myapp', on_event_c, {match: 'prefix'}));
dl2.push(session_d.subscribe('com', on_event_d, {match: 'prefix'}));
dl2.push(session_e.subscribe('com.myapp.topic1', on_event_e, {match: 'exact'}));
dl2.push(session_b.subscribe('com..topic1', on_event, {match: 'wildcard'}));
dl2.push(session_c.subscribe('com.myapp', on_event, {match: 'prefix'}));
dl2.push(session_d.subscribe('com', on_event, {match: 'prefix'}));
dl2.push(session_e.subscribe('com.myapp.topic1', on_event, {match: 'exact'}));

autobahn.when.all(dl2).then(
function (subs) {
Expand Down
18 changes: 9 additions & 9 deletions test/test_pubsub_multiple_matching_subs.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
0 "all sessions connected"
1 "event_e: args=" ["hello subscriber!",1] ", kwargs=" {}
1 "event: args=" ["hello subscriber!",1] ", kwargs=" {}
2 "subscription: sub_topic=" "com.myapp.topic1" ", sub_match=" "exact" ", session_ident=" "E"
3 "event_d: args=" ["hello subscriber!",1] ", kwargs=" {}
3 "event: args=" ["hello subscriber!",1] ", kwargs=" {}
4 "subscription: sub_topic=" "com" ", sub_match=" "prefix" ", session_ident=" "D"
5 "event_c: args=" ["hello subscriber!",1] ", kwargs=" {}
5 "event: args=" ["hello subscriber!",1] ", kwargs=" {}
6 "subscription: sub_topic=" "com.myapp" ", sub_match=" "prefix" ", session_ident=" "C"
7 "event_b: args=" ["hello subscriber!",1] ", kwargs=" {}
7 "event: args=" ["hello subscriber!",1] ", kwargs=" {}
8 "subscription: sub_topic=" "com..topic1" ", sub_match=" "wildcard" ", session_ident=" "B"
9 "event_d: args=" ["hello subscriber!",2] ", kwargs=" {}
9 "event: args=" ["hello subscriber!",2] ", kwargs=" {}
10 "subscription: sub_topic=" "com" ", sub_match=" "prefix" ", session_ident=" "D"
11 "event_c: args=" ["hello subscriber!",2] ", kwargs=" {}
11 "event: args=" ["hello subscriber!",2] ", kwargs=" {}
12 "subscription: sub_topic=" "com.myapp" ", sub_match=" "prefix" ", session_ident=" "C"
13 "event_d: args=" ["hello subscriber!",3] ", kwargs=" {}
13 "event: args=" ["hello subscriber!",3] ", kwargs=" {}
14 "subscription: sub_topic=" "com" ", sub_match=" "prefix" ", session_ident=" "D"
15 "event_c: args=" ["hello subscriber!",3] ", kwargs=" {}
15 "event: args=" ["hello subscriber!",3] ", kwargs=" {}
16 "subscription: sub_topic=" "com.myapp" ", sub_match=" "prefix" ", session_ident=" "C"
17 "event_d: args=" ["hello subscriber!",5] ", kwargs=" {}
17 "event: args=" ["hello subscriber!",5] ", kwargs=" {}
18 "subscription: sub_topic=" "com" ", sub_match=" "prefix" ", session_ident=" "D"
19 "closing .."

0 comments on commit a4556aa

Please sign in to comment.