Basic TCP connections

This commit is contained in:
Tony Bark 2025-02-18 14:29:18 -05:00
parent cd3ef1c3da
commit 60d28a2879
20 changed files with 968 additions and 30 deletions

34
client/source/GameScn.gd Normal file
View file

@ -0,0 +1,34 @@
extends Node
var client: StreamPeerTCP
func _ready() -> void:
GameKit.is_game_paused(false)
await get_tree().create_timer(1).timeout
connect_to_server()
func _process(delta):
if client == null:
return
client.poll()
if client.get_status() != StreamPeerTCP.STATUS_CONNECTED:
return
if Input.is_action_pressed("ui_pause"):
GameKit.is_game_paused(true)
$PauseScn/PauseWin.move_to_center();
$PauseScn/PauseWin.show()
func connect_to_server() -> void:
client = StreamPeerTCP.new()
var err = client.connect_to_host("127.0.0.1", 1337)
if err != OK:
print(err)
func _on_timer_timeout() -> void:
if client.get_status() != StreamPeerTCP.STATUS_CONNECTED:
return
client.put_data("This is Legends Online.".to_utf8_buffer())