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
Mar 26, 2017
1 parent
f10113a
commit 4e99659
Showing
6 changed files
with
146 additions
and
25 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
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
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
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,93 @@ | ||
/////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// AutobahnJS - http://autobahn.ws, http://wamp.ws | ||
// | ||
// A JavaScript library for WAMP ("The Web Application Messaging Protocol"). | ||
// | ||
// Copyright (c) Crossbar.io Technologies GmbH and contributors | ||
// | ||
// Licensed under the MIT License. | ||
// http://www.opensource.org/licenses/mit-license.php | ||
// | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
var autobahn = require('./../index.js'); | ||
var testutil = require('./testutil.js'); | ||
|
||
exports.testRawSocketTransport = function (testcase) { | ||
|
||
testcase.expect(1); | ||
|
||
var test = new testutil.Testlog("test/test_rawsocket_transport.txt"); | ||
var N = 2; | ||
|
||
test.log("connecting " + N + " sessions ..."); | ||
|
||
var connection_config = { | ||
realm: testutil.config.realm, | ||
transports: [ | ||
{ | ||
type: 'rawsocket', | ||
host: '127.0.0.1', | ||
port: 8080 | ||
} | ||
], | ||
// FIXME - serializer is ignored! sth wrong | ||
serializers: [ | ||
new autobahn.serializer.MsgpackSerializer() | ||
], | ||
protocols: ['wamp.2.msgpack'] | ||
}; | ||
|
||
var dl = testutil.connect_n(N, connection_config); | ||
|
||
autobahn.when.all(dl).then( | ||
function (res) { | ||
test.log("all " + res.length + " sessions connected"); | ||
|
||
for (var i = 0; i < res.length; ++i) { | ||
test.log("session._socket.info", res[i]._socket.info); | ||
} | ||
|
||
var session1 = res[0]; | ||
var session2 = res[1]; | ||
|
||
var counter = 0; | ||
|
||
var t1 = setInterval(function () { | ||
test.log("publishing to topic 'com.myapp.topic1': " + counter); | ||
session1.publish('com.myapp.topic1', [counter]); | ||
counter += 1; | ||
}, 100); | ||
|
||
var received = 0; | ||
|
||
var sub; | ||
function onevent1(args) { | ||
test.log("Got event:", args[0]); | ||
received += 1; | ||
if (received > 5) { | ||
test.log("Closing .."); | ||
|
||
clearInterval(t1); | ||
|
||
session1.leave(); | ||
session2.leave(); | ||
|
||
var chk = test.check() | ||
testcase.ok(!chk, chk); | ||
testcase.done(); | ||
} | ||
} | ||
|
||
sub = session2.subscribe('com.myapp.topic1', onevent1); | ||
}, | ||
function (err) { | ||
test.log(err); | ||
|
||
var chk = test.check(); | ||
testcase.ok(!chk, chk); | ||
testcase.done(); | ||
} | ||
); | ||
} |
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,17 @@ | ||
0 "connecting 2 sessions ..." | ||
1 "all 2 sessions connected" | ||
2 "session._socket.info" {"protocol":"wamp.2.json","type":"rawsocket","url":null} | ||
3 "session._socket.info" {"protocol":"wamp.2.json","type":"rawsocket","url":null} | ||
4 "publishing to topic 'com.myapp.topic1': 0" | ||
5 "Got event:" 0 | ||
6 "publishing to topic 'com.myapp.topic1': 1" | ||
7 "Got event:" 1 | ||
8 "publishing to topic 'com.myapp.topic1': 2" | ||
9 "Got event:" 2 | ||
10 "publishing to topic 'com.myapp.topic1': 3" | ||
11 "Got event:" 3 | ||
12 "publishing to topic 'com.myapp.topic1': 4" | ||
13 "Got event:" 4 | ||
14 "publishing to topic 'com.myapp.topic1': 5" | ||
15 "Got event:" 5 | ||
16 "Closing .." |
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