forked from crossbario/autobahn-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tobias Oberstein
committed
Feb 16, 2015
1 parent
dff4b3e
commit 287b2b2
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// AutobahnJS - http://autobahn.ws, http://wamp.ws | ||
// | ||
// A JavaScript library for WAMP ("The Web Application Messaging Protocol"). | ||
// | ||
// Copyright (C) 2011-2015 Tavendo GmbH, http://tavendo.com | ||
// | ||
// Licensed under the MIT License. | ||
// http://www.opensource.org/licenses/mit-license.php | ||
// | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
var autobahn = require('./../index.js'); | ||
var testutil = require('./testutil.js'); | ||
|
||
|
||
exports.testPubsubPrefixSub = function (testcase) { | ||
|
||
testcase.expect(1); | ||
|
||
var test = new testutil.Testlog("test/test_pubsub_wildcard_sub.txt"); | ||
|
||
var dl = testutil.connect_n(2); | ||
|
||
autobahn.when.all(dl).then( | ||
function (res) { | ||
test.log("all sessions connected"); | ||
|
||
var session1 = res[0]; | ||
var session2 = res[1]; | ||
var received = 0; | ||
|
||
function onevent1 (args) { | ||
test.log("Got event:", args); | ||
received += 1; | ||
if (received >= 2) { | ||
test.log("Closing .."); | ||
|
||
session1.leave(); | ||
session2.leave(); | ||
|
||
var chk = test.check() | ||
testcase.ok(!chk, chk); | ||
testcase.done(); | ||
} | ||
} | ||
|
||
var options = {match: 'wildcard'}; | ||
var msg = "Hello wildcard pattern subscriber!"; | ||
var counter = 0; | ||
|
||
console.log("HERE ", options); | ||
|
||
session2.subscribe('com.example..create', onevent1, options).then( | ||
function (subscription) { | ||
// these are all received | ||
session1.publish('com.example.foobar.create', [msg, counter++]); | ||
session1.publish('com.example.1.create', [msg, counter++]); | ||
|
||
// these are not received | ||
session1.publish('com.example.foobar.delete', [msg, counter++]); | ||
session1.publish('com.example.foobar.create2', [msg, counter++]); | ||
session1.publish('com.example.foobar.create.barbaz', [msg, counter++]); | ||
session1.publish('com.example.foobar', [msg, counter++]); | ||
session1.publish('com.example.create', [msg, counter++]); | ||
session1.publish('com.example', [msg, counter++]); | ||
}, | ||
function (err) { | ||
test.log(err); | ||
} | ||
); | ||
}, | ||
function (err) { | ||
test.log(err); | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
0 "all sessions connected" | ||
1 "Got event:" ["Hello wildcard pattern subscriber!",0] | ||
2 "Got event:" ["Hello wildcard pattern subscriber!",1] | ||
3 "Closing .." |