Basically I need to feed "events" back to the central server using gdscript. i.e. User picked up this, user dropped this, etc.... Im assuming the mobile phone holds an "event queue" that needs to be shipped off to the server. HTTPS is fine for my purposes. (A technique that would apply to any application that needs to share activity events between applications)
How does one implement a queue/thread in gdscript to handle this activity?
Im inclined to drop events into an sqlite database, then have some kind of "thread" that picks up and retries sending the events. Is this something that is normally coded from scratch? How do you do threads? If there are not threads, how do you handle when a http request fails, how do you ensure that something retries the message.
At this point in time, there does not appear to be a standardized/built in event queue style framework.
A simple class/node with an array acting as a queue works well with a simple function to queue messages. This demonstrates submitting a http request, where a callback is made to a function called http_result
when the request is complete or fails.
http_request = HTTPRequest.new()
add_child(http_request)
http_request.connect("request_completed", self, "http_result")
http result handling:
func signin_status(result, response_code, headers, body):
if response_code == 200:
var data = parse_json(body.get_string_from_utf8())
print("json: ", data)
print("headers: ", headers)
else:
print("http response: ", response_code, " CODE: ", result, " data:", body.get_string_from_utf8())
remove_child(http_request)
http_request = null