window.api = new ApiClient();
window.api.onFailed(e => toast(e.message));

(function () {

    window.ws = new WebSocketClient();

    api.get("/api/info", (r) => {
        if (r.data.webSocketPort) {
            var host = window.location.hostname;
            var port = String(r.data.webSocketPort);
            var url = "ws://" + host + ":" + port;
            ws.connect(url);
        }
    });

})();



