diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-05-05 15:12:36 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-05-05 15:12:36 -0400 |
commit | 574922e37337690b4499427ea42ba12985ac9bee (patch) | |
tree | 7cdfb9be86a986848a522626012a3e60dd28d0aa | |
parent | 5ffe823397bf047b366ac0be07388c5f36f05ccb (diff) | |
download | lingo-archipelago-574922e37337690b4499427ea42ba12985ac9bee.tar.gz lingo-archipelago-574922e37337690b4499427ea42ba12985ac9bee.tar.bz2 lingo-archipelago-574922e37337690b4499427ea42ba12985ac9bee.zip |
Added wss support
-rw-r--r-- | Archipelago/client.gd | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/Archipelago/client.gd b/Archipelago/client.gd index a1ba64d..b7050b6 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd | |||
@@ -45,6 +45,7 @@ const kREARRANGE_PANELS = 1 | |||
45 | var _client = WebSocketClient.new() | 45 | var _client = WebSocketClient.new() |
46 | var _should_process = false | 46 | var _should_process = false |
47 | var _initiated_disconnect = false | 47 | var _initiated_disconnect = false |
48 | var _try_wss = false | ||
48 | 49 | ||
49 | var _datapackages = {} | 50 | var _datapackages = {} |
50 | var _pending_packages = [] | 51 | var _pending_packages = [] |
@@ -134,13 +135,17 @@ func _reset_state(): | |||
134 | 135 | ||
135 | 136 | ||
136 | func _errored(): | 137 | func _errored(): |
137 | global._print("AP connection failed") | 138 | if _try_wss: |
138 | _reset_state() | 139 | global._print("Could not connect to AP with ws://, now trying wss://") |
140 | connectToServer() | ||
141 | else: | ||
142 | global._print("AP connection failed") | ||
143 | _reset_state() | ||
139 | 144 | ||
140 | emit_signal( | 145 | emit_signal( |
141 | "could_not_connect", | 146 | "could_not_connect", |
142 | "Could not connect to Archipelago. Check that your server and port are correct. See the error log for more information." | 147 | "Could not connect to Archipelago. Check that your server and port are correct. See the error log for more information." |
143 | ) | 148 | ) |
144 | 149 | ||
145 | 150 | ||
146 | func _closed(_was_clean = true): | 151 | func _closed(_was_clean = true): |
@@ -155,6 +160,7 @@ func _closed(_was_clean = true): | |||
155 | 160 | ||
156 | func _connected(_proto = ""): | 161 | func _connected(_proto = ""): |
157 | global._print("Connected!") | 162 | global._print("Connected!") |
163 | _try_wss = false | ||
158 | 164 | ||
159 | 165 | ||
160 | func disconnect_from_ap(): | 166 | func disconnect_from_ap(): |
@@ -440,7 +446,17 @@ func getSaveFileName(): | |||
440 | func connectToServer(): | 446 | func connectToServer(): |
441 | _initiated_disconnect = false | 447 | _initiated_disconnect = false |
442 | 448 | ||
443 | var url = "ws://" + ap_server | 449 | var url = "" |
450 | if ap_server.begins_with("ws://") or ap_server.begins_with("wss://"): | ||
451 | url = ap_server | ||
452 | _try_wss = false | ||
453 | elif _try_wss: | ||
454 | url = "wss://" + ap_server | ||
455 | _try_wss = false | ||
456 | else: | ||
457 | url = "ws://" + ap_server | ||
458 | _try_wss = true | ||
459 | |||
444 | var err = _client.connect_to_url(url) | 460 | var err = _client.connect_to_url(url) |
445 | if err != OK: | 461 | if err != OK: |
446 | emit_signal( | 462 | emit_signal( |