-
-
Save darkl/ab4003af525c4eb2500a to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<body> | |
<h1>Hello WAMP</h1> | |
<p>Open JavaScript console to watch output.</p> | |
<script>AUTOBAHN_DEBUG = true;</script> | |
<script src="http://autobahn.s3.amazonaws.com/autobahnjs/latest/autobahn.min.jgz"></script> | |
<script> | |
// the URL of the WAMP Router (Crossbar.io) | |
// | |
var wsuri = "ws://127.0.0.1:8080/ws"; | |
// the WAMP connection to the Router | |
// | |
var connection = new autobahn.Connection({ | |
url: wsuri, | |
realm: "realm1" | |
}); | |
// fired when connection is established and session attached | |
// | |
connection.onopen = function(session, details) { | |
console.log("Connected"); | |
// SUBSCRIBE to a topic and receive events | |
// | |
function on_counter(args) { | |
var counter = args[0]; | |
console.log("on_counter() event received with counter " + counter); | |
} | |
for (var i = 0; i < 800; i++) { | |
session.subscribe('com.example.oncounter' + i, on_counter).then( | |
function(sub) { | |
console.log('subscribed to topic'); | |
}, | |
function(err) { | |
console.log('failed to subscribe to topic', err); | |
} | |
); | |
} | |
} | |
connection.open(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment