Skip to content
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

Continuous refresh of websocket data on webpage #283

Open
MikeSoperRubicon opened this issue Mar 17, 2022 · 1 comment
Open

Continuous refresh of websocket data on webpage #283

MikeSoperRubicon opened this issue Mar 17, 2022 · 1 comment

Comments

@MikeSoperRubicon
Copy link

Hi there,

I'm using your fantastic framework to write a custom application with your framework as the frontend.
I'm streaming serial data into the ESP and saving it using _state.myVariable
I then display this on the webpage using the websocket end point. What I'd like is continuous refresh when the variables are updated with new values from the serial stream. If I use the callUpdateHandlers function periodically, then the websocket page refreshes but the functionality to submit changes to variables using the rest fails. I suspect this is because of the multiple threads running and accessing the same memory at the same time. Do you perhaps have any suggestions on how I could send data to the websocket directly from my application?

Useful information: My application and your framework are running as two separate RTOS tasks.

@rjwats
Copy link
Owner

rjwats commented Mar 18, 2022

If you are updating _state.myVariable directly (assuming _state is on your StatefulService instance) you will be bypassing the observer pattern and the propagation events won't trigger, which may explain your issue getting WS events to your client.

The docs talk a little bit about this here:

https://github.com/rjwats/esp8266-react#stateful-service

If it's still not working for you, can provide a code sample? I may be able to help further.

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

2 participants