Working Code

Create a Plugin with this code, for Working Sammi Socket Connection.
This commit is contained in:
Mario Steele 2025-04-30 04:09:20 -05:00
parent 03c0c804b0
commit eacd8d72af
5 changed files with 33 additions and 5 deletions

18
test_godot.gd Normal file
View file

@ -0,0 +1,18 @@
extends Node2D
@onready var http_request: HTTPRequest = $HTTPRequest
func _ready() -> void:
http_request.request_completed.connect(_request_data)
http_request.request("http://localhost:9450/api?getVariable=somevariable")
func _request_data(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray) -> void:
print("Result: %d" % result)
print("Response Code: %d" % response_code)
print("Headers:", JSON.stringify(headers, "\t"))
var data := body.get_string_from_utf8()
var d: Dictionary = JSON.parse_string(data)
print("Body (str): ", body.get_string_from_utf8())
print("Body (JSON): ", JSON.stringify(d, "\t"))
print("Completed")