UWMRO/Instruments

Implement API hooks/unpolled messages

Opened this issue · 0 comments

Right now all the information the client receives is polled; that is, the user need to press a button that sends a request to the server which returns some information that is then displayed.

This is fine in general but there are two downsides:

  • There may be some information that one wants to monitor more or less continuously, like the temperature of the camera. That can be implemented as an effect in React, but it can be easier if the server sends some status information unpolled.
  • Some actions may be long-running, like taking an exposure or moving a filter wheel. In that case RESTful API are not the best for long processing requests. For example, if one refreshes the page, the request that is handling the exposure will fail and it's not possible to know if the exposure finished (although the exposure in the server will still be going).

One solution may be to implement websockets. Another can be adding some hooks for the server to send information to the client

https://nordicapis.com/stop-polling-and-consider-using-rest-hooks/

Also in general, it's probably better to not have a very long running route like /capture that can take minutes to run. Instead one could have something like /startExposure, /exposureStatus, /getImage, etc.