stop using a hardcoded websocket address in ws_client

This commit is contained in:
zapashcanon 2023-01-03 23:53:05 +01:00
parent caffcbb527
commit cdd46850bf
No known key found for this signature in database
GPG key ID: 8981C3C62D1D28F1

View file

@ -5,8 +5,14 @@ open Shared
let ws = let ws =
Format.printf "create websocket@\n"; Format.printf "create websocket@\n";
let ws_url = let ws_url =
(* TODO fix hostname *) let location = Window.location G.window in
Jstr.of_string "ws://localhost:3696/island/ws" let host = Uri.host location |> Jstr.to_string in
let port =
Option.fold ~none:""
~some:(fun port -> Format.sprintf ":%d" port)
(Uri.port location)
in
Jstr.of_string @@ Format.sprintf "ws://%s%s/island/ws" host port
in in
Websocket.create ws_url Websocket.create ws_url