File: index.html

package info (click to toggle)
autobahn-cpp 17.5.1%2Bgit7cc5d37-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 792 kB
  • sloc: cpp: 2,133; makefile: 3
file content (54 lines) | stat: -rw-r--r-- 1,661 bytes parent folder | download | duplicates (4)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html>
   <body>
      <h1>WAMP Frontend</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:8080/ws',
            realm: 'realm1'}
         );

         connection.onopen = function (session, details) {

            console.log("Connected", details);

            var cnt = 0;

            function on_topic1(args) {
               cnt += 1;
               console.log("Got " + cnt + "-th event on topic1:", args[0]);
            }
            session.subscribe('com.examples.subscriptions.topic1', on_topic1);

            session.call('com.examples.calculator.add2', [23, 777]).then(
               function (res) {
                  console.log("Call succeeded. Result:", res);
               },
               function (err) {
                  console.log(err);
               }
            );

            session.call('com.myapp.longop', [3], {}, { receive_progress: true }).then(
                  function (res) {
                      console.log("Final:", res);
                      connection.close();
                  },
                  function (err) {
                  },
                  function (progress) {
                      console.log("Progress:", progress);
                  }
               );
         };

         connection.onclose = function (reason, details) {
            console.log("Connection closed", reason, details);
         }

         connection.open();
      </script>
   </body>
</html>