-
Notifications
You must be signed in to change notification settings - Fork 6
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
Showing
8 changed files
with
112 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// AUTOBAHN_DEBUG = true; | ||
const autobahn = require('autobahn') | ||
const program = require('commander') | ||
|
||
program | ||
.option('-s, --server <server>', 'Server URI address', 'ws://127.0.0.1:9000/wamp') | ||
.parse(process.argv) | ||
|
||
console.log('connect to server:', program.server) | ||
|
||
var user = "joe" | ||
var key = "joe-secret" | ||
|
||
// this callback is fired during authentication | ||
function onchallenge (session, method, extra) { | ||
if (method === "ticket") { | ||
return key | ||
} else { | ||
throw "don't know how to authenticate using '" + method + "'" | ||
} | ||
} | ||
|
||
var connection = new autobahn.Connection({ | ||
url: program.server, | ||
realm: 'realm1', | ||
authmethods: ["ticket", "wampcra"], | ||
authid: user, | ||
onchallenge: onchallenge | ||
}) | ||
|
||
const msgCount = 100000 | ||
|
||
connection.onopen = function (session, details) { | ||
|
||
session.log("Session open.") | ||
|
||
var starttime = Date.now() | ||
var res = [] | ||
for (var i=0; i<msgCount; i++) { | ||
res.push(session.publish('com.myapp.topic1', [], {field1:'some long value', field2:12345}, { acknowledge : true }).then( | ||
function(publication) { | ||
// console.log("published, publication ID is ", publication); | ||
}, | ||
function(error) { | ||
console.log("publication error", error) | ||
return Promise.resolve(true) | ||
} | ||
)) | ||
} | ||
|
||
// when progressive call and acknowledge publish done | ||
Promise.all(res).then(function () { | ||
console.log('total rec/sec:', msgCount/(Date.now() - starttime)*1000 ) | ||
connection.close(); | ||
}) | ||
} | ||
|
||
connection.onclose = function (reason, details) { | ||
console.log("close connection:", reason, details) | ||
} | ||
|
||
connection.open() |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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