show identity info

This commit is contained in:
liamcottle
2024-04-29 22:28:34 +12:00
parent 27ae81180e
commit f5b5970eec
2 changed files with 47 additions and 3 deletions

View File

@@ -64,8 +64,10 @@
<!-- middle -->
<div class="flex h-full w-full px-2 space-x-2">
<!-- peers -->
<div class="w-72 h-full py-2">
<!-- sidebar -->
<div class="flex flex-col w-80 h-full py-2 space-y-2">
<!-- peers -->
<div class="border rounded-xl bg-white h-full shadow">
<div class="flex border-b border-gray-300 text-gray-700 p-2">
<div class="mr-2">
@@ -87,6 +89,29 @@
</div>
</div>
</div>
<!-- my identity -->
<div v-if="config" class="border rounded-xl bg-white shadow">
<div class="flex border-b border-gray-300 text-gray-700 p-2">
<div class="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">
<path stroke-linecap="round" stroke-linejoin="round" d="M17.982 18.725A7.488 7.488 0 0 0 12 15.75a7.488 7.488 0 0 0-5.982 2.975m11.963 0a9 9 0 1 0-11.963 0m11.963 0A8.966 8.966 0 0 1 12 21a8.966 8.966 0 0 1-5.982-2.275M15 9.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
</svg>
</div>
<div>My Identity</div>
</div>
<div class="divide-y text-gray-900">
<div class="p-1">
<div>Identity Hash</div>
<div class="text-sm text-gray-700">{{ config.identity_hash }}</div>
</div>
<div class="p-1">
<div>LXMF Address Hash</div>
<div class="text-sm text-gray-700">{{ config.lxmf_address_hash }}</div>
</div>
</div>
</div>
</div>
<!-- chat view -->
@@ -221,6 +246,8 @@
isSendingMessage: false,
autoScrollOnNewMessage: true,
config: null,
peers: {},
selectedPeer: null,
chatItems: [],
@@ -253,6 +280,10 @@
this.ws.onmessage = (message) => {
const json = JSON.parse(message.data);
switch(json.type){
case 'config': {
this.config = json.config;
break;
}
case 'announce': {
this.peers[json.destination_hash] = {
destination_hash: json.destination_hash,

15
web.py
View File

@@ -77,6 +77,9 @@ class ReticulumWebChat:
# add client to connected clients list
self.websocket_clients.append(client)
# send config to all clients
self.send_config_to_websocket_clients()
# handle client messages until disconnected
while True:
try:
@@ -126,7 +129,17 @@ class ReticulumWebChat:
# broadcast provided data to all connected websocket clients
def websocket_broadcast(self, data):
for websocket_client in self.websocket_clients:
asyncio.run(websocket_client.send(data))
asyncio.create_task(websocket_client.send(data))
# broadcasts config to all websocket clients
def send_config_to_websocket_clients(self):
self.websocket_broadcast(json.dumps({
"type": "config",
"config": {
"identity_hash": self.identity.hexhash,
"lxmf_address_hash": self.local_lxmf_destination.hexhash,
},
}))
# handle an lxmf delivery from reticulum
def on_lxmf_delivery(self, message):