This repository has been archived on 2023-12-19. You can view files and clone it, but cannot push or open issues or pull requests.
MUR/scripts/networking/game_server_requests.gd

35 lines
1.0 KiB
GDScript3
Raw Permalink Normal View History

extends Spatial
class_name GameServerRequests
var http:HTTPRequest
func _ready():
http = HTTPRequest.new()
add_child(http)
http.connect("request_completed",self, "_self_destroy")
func connect_http(node,function):
http.connect("request_completed",node,function)
func get_request(path:String):
http.request(game_server.get_api_addr() + path, game_server.get_headers(), game_server.get_ssl(), HTTPClient.METHOD_GET)
func post_request(path:String, data:String = ""):
http.request(game_server.get_api_addr() + path, game_server.get_headers(), game_server.get_ssl(), HTTPClient.METHOD_POST, data)
func put_request(path:String, data:String = ""):
http.request(game_server.get_api_addr() + path, game_server.get_headers(), game_server.get_ssl(), HTTPClient.METHOD_PUT, data)
func delete_request(path:String, data:String = ""):
http.request(game_server.get_api_addr() + path, game_server.get_headers(), game_server.get_ssl(), HTTPClient.METHOD_DELETE, data)
func _self_destroy(result, response_code, headers, body):
queue_free()