diff options
| author | RblSb <msrblsb@gmail.com> | 2024-08-15 08:29:24 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2024-08-15 08:33:17 +0300 |
| commit | 4ac52a44ced3691581a1390bbdbdc0906074b3f3 (patch) | |
| tree | db18acc64e20d5837c0ef92787ccf8ab1eb6af2d /src/client/Main.hx | |
| parent | 38cc0a1d9b4b146af7110c681389378fd26761fa (diff) | |
Add uuids for better reconection
Kick zombie users with same uuids.
Minimal node version is 14.
Diffstat (limited to 'src/client/Main.hx')
| -rw-r--r-- | src/client/Main.hx | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/client/Main.hx b/src/client/Main.hx index 8cdd914..6d50b5e 100644 --- a/src/client/Main.hx +++ b/src/client/Main.hx @@ -61,6 +61,7 @@ class Main { final defaults:ClientSettings = { version: SETTINGS_VERSION, + uuid: null, name: "", hash: "", isExtendedPlayer: false, @@ -124,7 +125,8 @@ class Main { final port = Browser.location.port; final colonPort = port.length > 0 ? ':$port' : port; final path = Browser.location.pathname; - ws = new WebSocket('$protocol//$host$colonPort$path'); + final query = settings.uuid == null ? "" : '?uuid=${settings.uuid}'; + ws = new WebSocket('$protocol//$host$colonPort$path$query'); ws.onmessage = onMessage; ws.onopen = () -> { disconnectNotification?.stop(); @@ -585,6 +587,10 @@ class Main { function onConnected(data:WsEvent):Void { final connected = data.connected; + + settings.uuid = connected.uuid; + Settings.write(settings); + globalIp = connected.globalIp; setConfig(connected.config); if (connected.isUnknownClient) { |
