diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-04-13 14:50:27 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-04-13 14:50:27 -0400 |
commit | b6b24b10c6fb056bfa297c6f3a6f29a9991f9fa1 (patch) | |
tree | da3931cd6df500e63162ef71d561b553e2e96b22 /Archipelago/client.gd | |
parent | 92b1c91d7d40dbb5d301d896c542d03b4b374075 (diff) | |
download | lingo-archipelago-b6b24b10c6fb056bfa297c6f3a6f29a9991f9fa1.tar.gz lingo-archipelago-b6b24b10c6fb056bfa297c6f3a6f29a9991f9fa1.tar.bz2 lingo-archipelago-b6b24b10c6fb056bfa297c6f3a6f29a9991f9fa1.zip |
Client authenticates now
Diffstat (limited to 'Archipelago/client.gd')
-rw-r--r-- | Archipelago/client.gd | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Archipelago/client.gd b/Archipelago/client.gd index 489ec70..62f4d71 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd | |||
@@ -4,6 +4,8 @@ var ap_server = "" | |||
4 | var ap_user = "" | 4 | var ap_user = "" |
5 | var ap_pass = "" | 5 | var ap_pass = "" |
6 | 6 | ||
7 | const ap_version = {"major": 0, "minor": 4, "build": 0, "class": "Version"} | ||
8 | |||
7 | var _client = WebSocketClient.new() | 9 | var _client = WebSocketClient.new() |
8 | var _last_state = WebSocketPeer.STATE_CLOSED | 10 | var _last_state = WebSocketPeer.STATE_CLOSED |
9 | var _should_process = false | 11 | var _should_process = false |
@@ -12,6 +14,15 @@ var _datapackage_checksum = "" | |||
12 | var _item_name_to_id = {} | 14 | var _item_name_to_id = {} |
13 | var _location_name_to_id = {} | 15 | var _location_name_to_id = {} |
14 | 16 | ||
17 | const uuid_util = preload("user://maps/Archipelago/vendor/uuid.gd") | ||
18 | |||
19 | var _authenticated = false | ||
20 | var _team = 0 | ||
21 | var _slot = 0 | ||
22 | var _players = [] | ||
23 | var _checked_locations = [] | ||
24 | var _slot_data = {} | ||
25 | |||
15 | 26 | ||
16 | func _init(): | 27 | func _init(): |
17 | global._print("Instantiated APClient") | 28 | global._print("Instantiated APClient") |
@@ -47,6 +58,7 @@ func _ready(): | |||
47 | func _closed(was_clean = false): | 58 | func _closed(was_clean = false): |
48 | global._print("Closed, clean: " + was_clean) | 59 | global._print("Closed, clean: " + was_clean) |
49 | _should_process = false | 60 | _should_process = false |
61 | _authenticated = false | ||
50 | 62 | ||
51 | 63 | ||
52 | func _connected(_proto = ""): | 64 | func _connected(_proto = ""): |
@@ -69,6 +81,9 @@ func _on_data(): | |||
69 | if message["datapackage_checksums"].has("Lingo"): | 81 | if message["datapackage_checksums"].has("Lingo"): |
70 | if _datapackage_checksum != message["datapackage_checksums"]["Lingo"]: | 82 | if _datapackage_checksum != message["datapackage_checksums"]["Lingo"]: |
71 | requestDatapackage() | 83 | requestDatapackage() |
84 | else: | ||
85 | connectToRoom() | ||
86 | |||
72 | elif cmd == "DataPackage": | 87 | elif cmd == "DataPackage": |
73 | if message["data"]["games"].has("Lingo"): | 88 | if message["data"]["games"].has("Lingo"): |
74 | var lingo_pkg = message["data"]["games"]["Lingo"] | 89 | var lingo_pkg = message["data"]["games"]["Lingo"] |
@@ -77,6 +92,20 @@ func _on_data(): | |||
77 | _location_name_to_id = lingo_pkg["location_name_to_id"] | 92 | _location_name_to_id = lingo_pkg["location_name_to_id"] |
78 | saveSettings() | 93 | saveSettings() |
79 | 94 | ||
95 | connectToRoom() | ||
96 | |||
97 | elif cmd == "Connected": | ||
98 | _authenticated = true | ||
99 | _team = message["team"] | ||
100 | _slot = message["slot"] | ||
101 | _players = message["players"] | ||
102 | _checked_locations = message["checked_locations"] | ||
103 | _slot_data = message["slot_data"] | ||
104 | |||
105 | elif cmd == "ConnectionRefused": | ||
106 | global._print("Connection to AP refused") | ||
107 | global._print(message) | ||
108 | |||
80 | 109 | ||
81 | func _process(_delta): | 110 | func _process(_delta): |
82 | if _should_process: | 111 | if _should_process: |
@@ -119,3 +148,21 @@ func sendMessage(msg): | |||
119 | 148 | ||
120 | func requestDatapackage(): | 149 | func requestDatapackage(): |
121 | sendMessage([{"cmd": "GetDataPackage", "games": ["Lingo"]}]) | 150 | sendMessage([{"cmd": "GetDataPackage", "games": ["Lingo"]}]) |
151 | |||
152 | |||
153 | func connectToRoom(): | ||
154 | sendMessage( | ||
155 | [ | ||
156 | { | ||
157 | "cmd": "Connect", | ||
158 | "password": ap_pass, | ||
159 | "game": "Lingo", | ||
160 | "name": ap_user, | ||
161 | "uuid": uuid_util.v4(), | ||
162 | "version": ap_version, | ||
163 | "items_handling": 0b111, # always receive our items | ||
164 | "tags": [], | ||
165 | "slot_data": true | ||
166 | } | ||
167 | ] | ||
168 | ) | ||