From f5b5970eeccb025d4d3507ed225677af39dd6dd8 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Mon, 29 Apr 2024 22:28:34 +1200 Subject: [PATCH] show identity info --- index.html | 35 +++++++++++++++++++++++++++++++++-- web.py | 15 ++++++++++++++- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 45dc244..1622d2c 100644 --- a/index.html +++ b/index.html @@ -64,8 +64,10 @@
- -
+ +
+ +
@@ -87,6 +89,29 @@
+ + +
+
+
+ + + +
+
My Identity
+
+
+
+
Identity Hash
+
{{ config.identity_hash }}
+
+
+
LXMF Address Hash
+
{{ config.lxmf_address_hash }}
+
+
+
+
@@ -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, diff --git a/web.py b/web.py index 8356e2a..1e55985 100644 --- a/web.py +++ b/web.py @@ -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):