show peers and be able to reply to them
This commit is contained in:
27
index.html
27
index.html
@@ -61,6 +61,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div @click="onPeerClick(peer)" v-for="peer of Object.values(peers)" class="cursor-pointer">
|
||||||
|
<span><{{ peer.destination_hash }}> {{ peer.app_data }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- chat items -->
|
<!-- chat items -->
|
||||||
<div id="messages" class="h-full overflow-y-scroll px-3 sm:px-0">
|
<div id="messages" class="h-full overflow-y-scroll px-3 sm:px-0">
|
||||||
<div class="max-w-xl mx-auto">
|
<div class="max-w-xl mx-auto">
|
||||||
@@ -142,12 +148,12 @@
|
|||||||
isWebsocketConnected: false,
|
isWebsocketConnected: false,
|
||||||
autoReconnectWebsocket: true,
|
autoReconnectWebsocket: true,
|
||||||
|
|
||||||
sendToDestinationHash: "bebfd1f0635a7f6129ee3b30c05328f3",
|
|
||||||
|
|
||||||
newMessageText: "",
|
newMessageText: "",
|
||||||
isSendingMessage: false,
|
isSendingMessage: false,
|
||||||
autoScrollOnNewMessage: true,
|
autoScrollOnNewMessage: true,
|
||||||
|
|
||||||
|
peers: {},
|
||||||
|
selectedPeer: null,
|
||||||
chatItems: [],
|
chatItems: [],
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -178,6 +184,13 @@
|
|||||||
this.ws.onmessage = (message) => {
|
this.ws.onmessage = (message) => {
|
||||||
const json = JSON.parse(message.data);
|
const json = JSON.parse(message.data);
|
||||||
switch(json.type){
|
switch(json.type){
|
||||||
|
case 'announce': {
|
||||||
|
this.peers[json.destination_hash] = {
|
||||||
|
destination_hash: json.destination_hash,
|
||||||
|
app_data: json.app_data,
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'lxmf.delivery': {
|
case 'lxmf.delivery': {
|
||||||
this.chatItems.push({
|
this.chatItems.push({
|
||||||
"source_hash": json.source_hash,
|
"source_hash": json.source_hash,
|
||||||
@@ -237,6 +250,11 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// do nothing if no peer selected
|
||||||
|
if(!this.selectedPeer){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.isSendingMessage = true;
|
this.isSendingMessage = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -244,7 +262,7 @@
|
|||||||
// send message to reticulum via websocket
|
// send message to reticulum via websocket
|
||||||
this.ws.send(JSON.stringify({
|
this.ws.send(JSON.stringify({
|
||||||
"type": "lxmf.delivery",
|
"type": "lxmf.delivery",
|
||||||
"destination_hash": this.sendToDestinationHash,
|
"destination_hash": this.selectedPeer.destination_hash,
|
||||||
"message": messageText,
|
"message": messageText,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -308,6 +326,9 @@
|
|||||||
window.open(fileUrl);
|
window.open(fileUrl);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
onPeerClick: function(peer) {
|
||||||
|
this.selectedPeer = peer;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isMobile() {
|
isMobile() {
|
||||||
|
|||||||
Reference in New Issue
Block a user