aboutsummaryrefslogtreecommitdiff
path: root/picarones-elm/index.html
blob: 66fe1581b493ad008fa66845d8eb78a402795264 (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
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="UTF-8">
  <title>Main</title>
  <script src="Main.js"></script>
  <link rel="stylesheet" type="text/css" href="document.css" />
</head>

<body>
  <div id="elm"></div>
  <script>
    var app = Elm.Main.init({
        node: document.getElementById('elm')
    });

    let ws = new WebSocket("ws://localhost:9160")
    
    ws.onopen = () => ws.send ("{\"room\":\"testroom\"}");

    ws.onmessage = function(msg) {
        console.log(msg.data)
        app.ports.recvPort.send(msg.data)
    }

    app.ports.sendPort.subscribe(function(msg) {
        ws.send(msg)
    })
  </script>
</body>
</html>