Advertisement
Guest User

Untitled

a guest
Jan 25th, 2012
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.26 KB | None | 0 0
  1.  <html>
  2.    <head>
  3.       <script src="http://code.jquery.com/jquery.min.js"></script>
  4.       <script src="http://www.tavendo.de/static/autobahn/autobahn-latest.js"></script>
  5.       <script>
  6.  
  7.          var sess = null;
  8.  
  9.          function onMeasure1(topicUri, event) {
  10.             //console.log(topicUri);
  11.             //console.log(event);
  12.             console.log("got measurement 1:")
  13.             console.log("temp = " + event[0])
  14.             console.log("humidity = " + event[1])
  15.          }
  16.  
  17.          function onKeepAlive(topicUri, event) {
  18.             //console.log(topicUri);
  19.             //console.log(event);
  20.             console.log("got keep alive " + event)
  21.          }
  22.  
  23.          $(document).ready(function()
  24.          {
  25.             sess = new ab.Session("ws://localhost:9000", function() {
  26.  
  27.                console.log("Connected!");
  28.  
  29.                sess.prefix("event", "http://example.com/mcu#");
  30.                sess.subscribe("event:measure1", onMeasure1);
  31.                sess.subscribe("event:keepalive", onKeepAlive);
  32.             });
  33.          });
  34.      </script>
  35.    </head>
  36.    <body>
  37.       <h1>Autobahn WebSockets: MCU to WS Gateway Demo</h1>
  38.       <p>Press F12 to open debugging console and see messages / events received</p>
  39.    </body>
  40.  </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement