From e8f03c4d6a94aa16b3587bdce525cf0cf7c6c6c3 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Tue, 14 Jan 2025 14:38:52 +0100 Subject: next commit --- network/server.gd | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'network/server.gd') diff --git a/network/server.gd b/network/server.gd index 3b3b9cd..efef6cb 100644 --- a/network/server.gd +++ b/network/server.gd @@ -14,9 +14,24 @@ var peer: StreamPeerTCP = StreamPeerTCP.new() func _init(host: String, port: int) -> void: self.host = host self.port = port + + +func establish_connection() -> Error: + var connection_result := peer.connect_to_host(host, port) + + if connection_result == Error.OK: + peer.poll() + + return connection_result + + +func get_status() -> Error: + if peer.get_status() in [StreamPeerTCP.STATUS_CONNECTING, StreamPeerTCP.STATUS_CONNECTED]: + return Error.OK + if peer.get_status() in [StreamPeerTCP.STATUS_NONE, StreamPeerTCP.STATUS_ERROR]: + return Error.FAILED - peer.connect_to_host(host, port) - peer.poll() + return Error.FAILED ## Emits [signal received_packet]. -- cgit v1.2.3