1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
<!doctype html>
<html>
<body>
<h1>Flask/Crochet/Autobahn: Example 2 (WAMP Client)</h1>
<p>Open JavaScript console to watch output.</p>
<script src="https://autobahn.s3.amazonaws.com/autobahnjs/latest/autobahn.min.jgz"></script>
<script>
var connection = new autobahn.Connection({
url: "ws://127.0.0.1:9000",
realm: 'realm1'
});
connection.onopen = function (session) {
console.log("connected");
session.call("com.example.slowsquare", [23]).then(
function (res) {
console.log("slow square result:", res);
},
function (err) {
console.log("error:", err);
}
);
session.call("com.example.square", [23]).then(
function (res) {
console.log("square result:", res);
},
function (err) {
console.log("error:", err);
}
);
};
connection.open();
</script>
</body>
</html>
|