extends HTTPRequest class_name DragonSharing signal on_dragon_received(dragon: DragonProperties) func _ready() -> void: request_completed.connect(_on_request_completed) func _on_request_completed(_result: int, response_code: int, _headers: PackedStringArray, body: PackedByteArray): if response_code != 200: print("HTTP request returned error: ", response_code) on_dragon_received.emit(null) return if body.size() != 0: var json = JSON.parse_string(body.get_string_from_utf8()) var properties = DragonProperties.new(json['name'], json['origin'], json['color'], json['hat'], json['shirt'], json['decor']) print(properties) on_dragon_received.emit(properties) func send(properties: DragonProperties) -> void: var url: String = 'http://torreta.gerardgascon.com/add/%s/%s/%s/%s/%s/%s/' % [properties.origin, properties.name, properties.color, properties.shirt, properties.hat, properties.decor] var err: int = request(url) if err != OK: print("HTTP request failed: ", err) func receive(origin: String) -> void: var url: String = 'http://torreta.gerardgascon.com/get/%s/' % origin var err: int = request(url) if err != OK: print("HTTP request failed: ", err)