diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2025-01-14 14:38:52 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2025-01-14 14:38:52 +0100 |
commit | e8f03c4d6a94aa16b3587bdce525cf0cf7c6c6c3 (patch) | |
tree | d8d5a78a0872b86c3b40089e465120883669542b /network/server.gd | |
parent | b75cc72c4e10bd652330b6d2bd99f3fd9129a3b3 (diff) |
next commit
Diffstat (limited to 'network/server.gd')
-rw-r--r-- | network/server.gd | 19 |
1 files changed, 17 insertions, 2 deletions
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]. |