add button and api to announce from call ui

This commit is contained in:
liamcottle
2024-05-21 04:01:38 +12:00
parent fc8af20201
commit 4d6beb4af8
2 changed files with 45 additions and 9 deletions

View File

@@ -149,10 +149,24 @@
<span>Initiate Call</span>
</button>
</div>
<div class="p-1">
<div class="flex p-1">
<div>
<div>My Destination Hash</div>
<div class="text-sm text-gray-700">{{ myAudioCallAddressHash || "Unknown" }}</div>
</div>
<div class="ml-auto my-auto mr-1">
<a @click="announce" href="javascript:void(0)" class="rounded-full">
<div class="flex text-gray-700 bg-gray-100 hover:bg-gray-200 px-2 py-1 rounded-full">
<div>
<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">
<path stroke-linecap="round" stroke-linejoin="round" d="M8.288 15.038a5.25 5.25 0 0 1 7.424 0M5.106 11.856c3.807-3.808 9.98-3.808 13.788 0M1.924 8.674c5.565-5.565 14.587-5.565 20.152 0M12.53 18.22l-.53.53-.53-.53a.75.75 0 0 1 1.06 0Z" />
</svg>
</div>
<div class="my-auto mx-1 text-sm">Announce</div>
</div>
</a>
</div>
</div>
</div>
<!-- active calls -->
@@ -645,6 +659,14 @@
}
},
async announce() {
try {
await window.axios.get(`/api/v1/announce`);
} catch(e) {
alert("failed to announce");
console.log(error);
}
},
},
computed: {
activeAudioCalls: function() {

26
web.py
View File

@@ -403,6 +403,16 @@ class ReticulumWebChat:
"message": "call has been hungup",
})
# announce
@routes.get("/api/v1/announce")
async def index(request):
self.announce()
return web.json_response({
"message": "announcing",
})
# serve announces
@routes.get("/api/v1/announces")
async def index(request):
@@ -611,6 +621,15 @@ class ReticulumWebChat:
app.on_startup.append(on_startup)
web.run_app(app, host=host, port=port)
# handle announcing
def announce(self):
# send announce for lxmf
self.local_lxmf_destination.announce(app_data=self.config.display_name.get().encode("utf-8"))
# send announce for audio call
self.audio_call_manager.announce(app_data=self.config.display_name.get().encode("utf-8"))
# handle data received from websocket client
async def on_websocket_data_received(self, client, data):
@@ -669,12 +688,7 @@ class ReticulumWebChat:
# handle sending an announce
elif _type == "announce":
# send announce for lxmf
self.local_lxmf_destination.announce(app_data=self.config.display_name.get().encode("utf-8"))
# send announce for audio call
self.audio_call_manager.announce(app_data=self.config.display_name.get().encode("utf-8"))
self.announce()
# handle downloading a file from a nomadnet node
elif _type == "nomadnet.file.download":