keep attempting to join call while the link is not yet established

This commit is contained in:
liamcottle
2024-05-20 23:59:16 +12:00
parent b1ec6ac608
commit b6ae483618
2 changed files with 27 additions and 4 deletions

View File

@@ -32,7 +32,7 @@
<path stroke-linecap="round" stroke-linejoin="round" d="M2.25 6.75c0 8.284 6.716 15 15 15h2.25a2.25 2.25 0 0 0 2.25-2.25v-1.372c0-.516-.351-.966-.852-1.091l-4.423-1.106c-.44-.11-.902.055-1.173.417l-.97 1.293c-.282.376-.769.542-1.21.38a12.035 12.035 0 0 1-7.143-7.143c-.162-.441.004-.928.38-1.21l1.293-.97c.363-.271.527-.734.417-1.173L6.963 3.102a1.125 1.125 0 0 0-1.091-.852H4.5A2.25 2.25 0 0 0 2.25 4.5v2.25Z" />
</svg>
</div>
<div class="my-auto">Reticulum Phone</div>
<div class="my-auto">Active Call</div>
</div>
<div class="border-b border-gray-300 text-gray-700 p-2">
@@ -105,7 +105,7 @@
</div>
<!-- call log -->
<div class="border rounded-xl bg-white shadow w-full overflow-hidden">
<div v-if="audioCalls.length > 0" class="border rounded-xl bg-white shadow w-full overflow-hidden">
<div class="flex border-b border-gray-300 text-gray-700 p-2">
<div class="my-auto mr-2">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
@@ -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;

2
web.py
View File

@@ -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