diff options
Diffstat (limited to 'client/index.html')
-rw-r--r-- | client/index.html | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/client/index.html b/client/index.html index 3803738..75ee56d 100644 --- a/client/index.html +++ b/client/index.html @@ -9,6 +9,17 @@ <script type="text/JavaScript" src="/assets/client.js"></script> <script> var app = Elm.Client.init({node: document.querySelector("main")}); + + var roomId = document.location.pathname.split("/")[2]; + var url = "ws://" + document.location.host + + "/rooms/" + roomId + "/events"; + var socket = new WebSocket(url); + app.ports.webSocketOut.subscribe(function(message) { + socket.send(message); + }); + socket.addEventListener("message", function(event) { + app.ports.webSocketIn.send(event.data); + }); </script> </body> </html> |