<!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> let args = location.hash.split("#").slice(1); var app = Elm.Main.init({ node: document.getElementById('elm'), flags: [args[0], parseInt(args[1])] }); let ws = new WebSocket("{{ serverurl }}") ws.onopen = () => ws.send (JSON.stringify ({room:args[0]})); 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>