I am working on a esp8266 library for using a web enable device (mostly just phones) to control a robot. The user connects to a server running on the esp and the library uses WebSockets to send updates about buttons, joysticks, and/or anything else.
The problem is that the data starts getting delayed and sometimes message get received very late, because it uses TCP (it would work better if those messages just didn't get delivered). Also since the esp has low memory this can causes it to crash.
How would I optimize this to update as fast as possible without receiving old messages?
Would something like WebRTC be better or is there something else more suited for this purpose? WebSockets using UDP seems like a better choice, but apparently browsers cannot send UDP?
What sort of stuff should look into/use?
By the way, if it helps, here is a link to my library.
Thanks for any help.