summaryrefslogtreecommitdiff
path: root/test/socket.html
blob: d110c81bbb82370a3379dc7cb1938a9b19522c35 (plain)
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
<html>
  <head>
    <title>rhimportd - Testclient</title>
    <style type="text/css">
      body {
        background-color: #555;
      }

      div.data {
        background-color: white;
        border: 1px solid;
        padding: 1em;
        font-family: monospace;
      }
    </style>
    <script src="jquery.min.js"></script>
    <script type="text/javascript">
      function Test() {
        this.sock = new WebSocket("ws://localhost:4080/trusted/socket");
        this.sock.onmessage = function (event) {
          $('#rawmsg').text(event.data);
        }
        this.seqnum = 0;
        this.update = function() {
          if ((this.seqnum % 15) == 0) {
            this.sock.send(JSON.stringify({ test: "hello world", seq: this.seqnum }));
          }
          this.seqnum += 1;
        }
      }

      function init() {
        test = new Test();
        setInterval(test.update.bind(test), 1000);
  //      test.update();
      }
    </script>
  </head>
  <body onload="init()">

    <h1>Radio Helsinki Rivendell Importer:</h1>

    <div id="rawmsg" class="data"></div>

  </body>
</html>