Reconnect the edits websocket if it disconnects (#4391)
* Reconnect the edits websocket if it disconnects * restart the server if the OS kills it * fix clippy * clean up code and add more comments * cleanups --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
1 parent
c5b33924ae
commit
3f62cd8fc0
9 files changed
+368
-188
No files matched your search
@@ -443,6 +443,24 @@ impl WebviewInstance {
|
||||
// Wait for work will return Ready when it has edits to be sent to the webview
|
||||
// It will return Pending when it needs to be polled again - nothing is ready
|
||||
loop {
|
||||
// Check if there is a new edit channel we need to send. On IOS,
|
||||
// the websocket will be killed when the device is put into sleep. If we
|
||||
// find the socket has been closed, we create a new socket and send it to
|
||||
// the webview to continue on
|
||||
// https://github.com/DioxusLabs/dioxus/issues/4374
|
||||
if self
|
||||
.edits
|
||||
.wry_queue
|
||||
.poll_new_edits_location(&mut cx)
|
||||
.is_ready()
|
||||
{
|
||||
_ = self.desktop_context.webview.evaluate_script(&format!(
|
||||
"window.interpreter.waitForRequest(\"{edits_path}\", \"{expected_key}\");",
|
||||
edits_path = self.edits.wry_queue.edits_path(),
|
||||
expected_key = self.edits.wry_queue.required_server_key()
|
||||
));
|
||||
}
|
||||
|
||||
// If we're waiting for a render, wait for it to finish before we continue
|
||||
let edits_flushed_poll = self.edits.wry_queue.poll_edits_flushed(&mut cx);
|
||||
if edits_flushed_poll.is_pending() {
|
||||
|
||||
Reference in new issue
Block a user