In the scenario where the plugin sends messages from the main thread to the UI, if the UI is not open in the browser when the plugin is opened, then the UI will miss these messages.
This is only an issue in the following scenarios:
- when the browser is opened after the plugin and messages are posted when the plugin loads.
- when dev server loses connection, like when your computer goes to sleep and the UI reconnects
It needs some thought on how to handle this as there could be multiple browser previews open. My first thought is that the websocket server should store messages first sent when the plugin is opened, queue them when the browser client is not connected and then send them when they are. I think this should be a one-time thing as in other cases, messages that are sent when the client is not available should be not be queued. Also messages that signify if a client is connected/disconnected should also not be queued.
Workaround for now
For now, the best way to avoid this issue is to request the data from the UI rather than posting from the main code. This ensures that the data is only sent to the UI when the UI is ready.
In the scenario where the plugin sends messages from the main thread to the UI, if the UI is not open in the browser when the plugin is opened, then the UI will miss these messages.
This is only an issue in the following scenarios:
It needs some thought on how to handle this as there could be multiple browser previews open. My first thought is that the websocket server should store messages first sent when the plugin is opened, queue them when the browser client is not connected and then send them when they are. I think this should be a one-time thing as in other cases, messages that are sent when the client is not available should be not be queued. Also messages that signify if a client is connected/disconnected should also not be queued.
Workaround for now
For now, the best way to avoid this issue is to request the data from the UI rather than posting from the main code. This ensures that the data is only sent to the UI when the UI is ready.