Skip to content

Implement API hooks/unpolled messages #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
albireox opened this issue Nov 10, 2022 · 0 comments
Open

Implement API hooks/unpolled messages #28

albireox opened this issue Nov 10, 2022 · 0 comments

Comments

@albireox
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant