extends Node const IP_ADDRESS: String = "127.0.0.1" const PORT: int = 25262 const MAX_CLIENTS: int = 1024 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(PORT, MAX_CLIENTS) != OK: Log.warning("Couldn't create the server at port %d!" % PORT) return multiplayer.multiplayer_peer = peer Log.info("Created the server at port %d." % PORT) # Connect to a server. func join_server() -> void: var peer: ENetMultiplayerPeer = ENetMultiplayerPeer.new() if peer.create_client(IP_ADDRESS, PORT) != OK: Log.warning("Couldn't connect to the server at %s:%d!" % [IP_ADDRESS, PORT]) return multiplayer.multiplayer_peer = peer Log.info("Connected to the server at %s:%d." % [IP_ADDRESS, PORT]) # Close all network connections. func close_network() -> void: multiplayer.multiplayer_peer = null Log.info("Closed all network connections.")