From b6ae4836186bfef7d23df67947f0036d4abd756e Mon Sep 17 00:00:00 2001 From: liamcottle Date: Mon, 20 May 2024 23:59:16 +1200 Subject: [PATCH] keep attempting to join call while the link is not yet established --- public/call.html | 29 ++++++++++++++++++++++++++--- web.py | 2 +- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/public/call.html b/public/call.html index 164377d..3b96a8e 100644 --- a/public/call.html +++ b/public/call.html @@ -32,7 +32,7 @@ -
Reticulum Phone
+
Active Call
@@ -105,7 +105,7 @@
-
+
@@ -152,6 +152,7 @@ audioCalls: [], + destinationHash: null, isInitiatingCall: false, isWebsocketConnected: false, @@ -209,7 +210,26 @@ const hash = response.data.hash; // join call - await this.joinCall(hash); + const maxJoinAttempts = 15; + for(var i = 0; i < maxJoinAttempts; i++){ + try { + + // wait 1 second before attempting to join call + await new Promise((resolve, reject) => setTimeout(resolve, 1000)); + + // attempt to join call + await this.joinCall(hash); + + // success, we no longer need to attempt to join + return; + + } catch(e) { + console.log(e); + } + } + + // failed to join call + alert("timed out attempting to join call"); } catch(e) { alert("failed to initiate call"); @@ -222,6 +242,9 @@ }, async joinCall(callHash) { + // update ui + this.callHash = callHash; + // reset stats this.txBytes = 0; this.rxBytes = 0; diff --git a/web.py b/web.py index 576f08a..d389ed7 100644 --- a/web.py +++ b/web.py @@ -292,7 +292,7 @@ class ReticulumWebChat: # convert hash to bytes audio_call_link_hash = bytes.fromhex(audio_call_link_hash) - # find audio call + # find audio call, this will be null until the link is established audio_call = self.audio_call_manager.find_audio_call_by_link_hash(audio_call_link_hash) if audio_call is None: # fixme: web browser expects websocket, so this won't be useful