<script src="http://autobahn.s3.amazonaws.com/js/autobahn.min.js"></script>
<script>
window.onload = function() {
// WAMP server
var wsuri = "ws://localhost:8080";
conn = ab.connect(wsuri,
// WAMP session was established
function (session) {
console.log(session);
session.subscribe("testChannel", function(topic, data) {
console.log(topic);
console.log(data);
});
/*
// asynchronous RPC, returns promise object
session.call("http://example.com/simple/calc#add", 23, 7).then(
// RPC success callback
function (res) {
console.log("got result: " + res);
},
// RPC error callback
function (error) {
console.group("Error");
console.group("URI");
console.log(error.uri);
console.groupEnd();
console.group("Description");
console.log(error.desc);
console.groupEnd();
console.group("Detail");
console.log(error.detail);
console.groupEnd();
console.groupEnd();
}
);
*/
},
// WAMP session is gone
function (code, reason) {
console.log(reason);
}
);
console.log(conn);
};
</script>
|