diff options
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(): |