diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-11-27 14:36:20 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-11-27 14:36:20 +0100 |
commit | a854a1862a30632e49520f6e1e11333d5c8ff241 (patch) | |
tree | 2b10c4d19bb66b270a7726d660ed85d7fcf9482e /Game/Network.gd | |
parent | cb9bb9d1c757b53707c741a3c8c218b513ffb5ec (diff) |
next commit
Diffstat (limited to 'Game/Network.gd')
-rw-r--r-- | Game/Network.gd | 19 |
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(): |