summaryrefslogtreecommitdiff
path: root/Game/Network.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-11-27 14:36:20 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-11-27 14:36:20 +0100
commita854a1862a30632e49520f6e1e11333d5c8ff241 (patch)
tree2b10c4d19bb66b270a7726d660ed85d7fcf9482e /Game/Network.gd
parentcb9bb9d1c757b53707c741a3c8c218b513ffb5ec (diff)
next commit
Diffstat (limited to 'Game/Network.gd')
-rw-r--r--Game/Network.gd19
1 files changed, 14 insertions, 5 deletions
diff --git a/Game/Network.gd b/Game/Network.gd
index 23542e2..2858d98 100644
--- a/Game/Network.gd
+++ b/Game/Network.gd
@@ -16,17 +16,25 @@ func _ready():
multiplayer.allow_object_decoding = true
-func host_game(port):
+func host_game(port) -> Error:
var peer = ENetMultiplayerPeer.new()
- peer.create_server(int(port))
+ var error = peer.create_server(int(port))
+
+ if error != OK:
+ return error
multiplayer.multiplayer_peer = peer
Client.player.id = multiplayer.get_unique_id()
+
+ return error
func join_game(ip, port):
var peer = ENetMultiplayerPeer.new()
- peer.create_client(ip, int(port))
+ var error = peer.create_client(ip, int(port))
+
+ if error != OK:
+ return error
multiplayer.multiplayer_peer = peer
@@ -37,8 +45,9 @@ func close_game():
multiplayer.multiplayer_peer = OfflineMultiplayerPeer.new()
reset_players()
- await Client.request(Client.game_lobby_url, [], HTTPClient.METHOD_POST, JSON.stringify({"close": Client.current_game_id}))
- Client.current_game_id = ""
+ await GameLobby.request_post("/close")
+ GameLobby.current_game_id = ""
+ GameLobby.current_secret = ""
func _on_connected_to_server():