0 votes

Is there a way to delay HTTPRequests?

I'm making a drawing app in Godot, it's linked to an API that saves drawings to a server. Everything is fine only the first time you press save on the drawing a 0KB file gets uploaded. Second time the button is pressed the drawing gets fully uploaded. What's more baffling is when a new drawing is made (either by clearing or drawing over the previous one), rather then save the new drawing, the previous drawing is saved on the first button press, and new drawing saved on second same button press.

The image is processed into base64 then sent to server where it's decoded and saved. I know it's not an API problem because when trying to send a local PNG file just wired to the button it works flawlessly. It's only when taking viewport data > processing > sending that this happens.

My theory is the time difference between Godot's processing the image and sending the data is too little. So back to my question, is there a way to delay HTTPRequests?

EDIT. As a test I made a second button, one to process the image, one to send the data. It works perfectly. What is happening?

asked Jun 23 in Engine by namathos (39 points)

1 Answer

+1 vote
Best answer

Found a way, nothing direct with HTTPRequest but using Timer node with it works. Followed things here: https://godotengine.org/qa/9758/timer-node-how-to-use-it-in-code

answered Jun 23 by namathos (39 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.