extends Node func test() -> void: start_server() join_server() close_network() # Start the network listener. func start_server() -> void: var peer: ENetMultiplayerPeer = ENetMultiplayerPeer.new() if peer.create_server(Game.PORT, Game.MAX_CLIENTS) != OK: Log.warning("Couldn't create the server at port %d!" % Game.PORT) return multiplayer.multiplayer_peer = peer Log.info("Created the server at port %d." % Game.PORT) # Connect to a server. func join_server() -> void: var peer: ENetMultiplayerPeer = ENetMultiplayerPeer.new() if peer.create_client(Game.IP_ADDRESS, Game.PORT) != OK: Log.warning("Couldn't connect to the server at %s:%d!" % [Game.IP_ADDRESS, Game.PORT]) return multiplayer.multiplayer_peer = peer Log.info("Connected to the server at %s:%d." % [Game.IP_ADDRESS, Game.PORT]) # Close all network connections. func close_network() -> void: multiplayer.multiplayer_peer = null Log.info("Closed all network connections.")