PhotonVision / photonvision

PhotonVision is the free, fast, and easy-to-use computer vision solution for the FIRST Robotics Competition.
https://photonvision.org
GNU General Public License v3.0
280 stars 202 forks source link

Make Client Side Websocket Requests Asynchronous #1386

Open srimanachanta opened 3 months ago

srimanachanta commented 3 months ago

Currently, websocket changes sent from the UI to the backend are just assumed to be successful, instead, the backend should return a WebsocketReponse struct similar to an HTTP response. By doing this, we can make sure that websocket-based changes are suspenseful.

To implement this we need to make the backend echo back a WebsocketReponse object back to the UI which has an async promise waiting for this message. Multiple requests can be handled by including the request handler within the response so the promise can determine the intended response. Also means that the API for this can be abstracted well for both the frontend and backend.

mcm001 commented 3 months ago

Mom can we have HTTP requests?

No, we have HTTP requests at home

HTTP at home:

Alextopher commented 3 months ago

I wonder if you could go into a bit more detail about what kind of improvements we'd see from this. Will this somehow communicate errors or just communicate the network delay to the user?