Doing a http.request, I use a success function which triggers when there is dataAvailable.
But what if no data can be found ?
Will the callback function time out or do I have to make another function to time out and return error.
A simple example would be nice
My run checks if a connection and data is available everytime a key is pressed and that causes a crash after a while when the requests has grown in numbers.
If no data is found, the request will still succeed but you will receive a 404 status code.
The docs have an example here:
The callback function can accept a
status parameter. This tells you the server’s response (such as 300 forbidden, 404 not found, 200 OK, 500 error, and so on).
The failure call will be called in the case where the server cannot be contacted.
So, I should handle the responce number inside my callback function before I try to process the data that is or is not received ? Does this to kill the callback before a new one is made ?
If status == 404 then print("not connected") else processdata() end
The problem I have is that the data amount could take several seconds to process. If multiple processses is awaiting this simply crashes Codea on exit.