mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
redesign of message transmission, implement retransmit
This commit is contained in:
parent
1a6c41a479
commit
34a4b30f10
3 changed files with 55 additions and 33 deletions
|
@ -115,24 +115,10 @@ export function newBroadcast(broadcastChannel, chatmessage) {
|
|||
// slice uuid for reducing overhead
|
||||
uuid = uuid.slice(-4);
|
||||
|
||||
var data_with_attachment =
|
||||
timestamp +
|
||||
split_char +
|
||||
chatmessage +
|
||||
split_char +
|
||||
filename +
|
||||
split_char +
|
||||
filetype +
|
||||
split_char +
|
||||
file;
|
||||
|
||||
var tnc_command = "broadcast";
|
||||
|
||||
sendMessage(dxcallsign, data_with_attachment, checksum, uuid, tnc_command);
|
||||
|
||||
let newChatObj = new Object();
|
||||
|
||||
newChatObj.command = "msg";
|
||||
newChatObj.command = "broadcast";
|
||||
newChatObj.hmac_signed = false;
|
||||
newChatObj.percent = 0;
|
||||
newChatObj.bytesperminute;
|
||||
|
@ -159,6 +145,8 @@ export function newBroadcast(broadcastChannel, chatmessage) {
|
|||
},
|
||||
};
|
||||
|
||||
sendMessage(newChatObj)
|
||||
|
||||
addObjToDatabase(newChatObj);
|
||||
}
|
||||
|
||||
|
@ -199,20 +187,6 @@ export function newMessage(
|
|||
// slice uuid for reducing overhead
|
||||
uuid = uuid.slice(-8);
|
||||
|
||||
var data_with_attachment =
|
||||
timestamp +
|
||||
split_char +
|
||||
chatmessage +
|
||||
split_char +
|
||||
filename +
|
||||
split_char +
|
||||
filetype +
|
||||
split_char +
|
||||
file;
|
||||
|
||||
var tnc_command = "msg";
|
||||
|
||||
sendMessage(dxcallsign, data_with_attachment, checksum, uuid, tnc_command);
|
||||
|
||||
let newChatObj = new Object();
|
||||
|
||||
|
@ -241,6 +215,7 @@ export function newMessage(
|
|||
},
|
||||
};
|
||||
|
||||
sendMessage(newChatObj);
|
||||
addObjToDatabase(newChatObj);
|
||||
}
|
||||
|
||||
|
@ -265,10 +240,25 @@ function sortChatList() {
|
|||
|
||||
//repeat a message
|
||||
export function repeatMessageTransmission(id) {
|
||||
console.log(id);
|
||||
// 1. get message object by ID
|
||||
// 2. Upsert Attempts
|
||||
// 3. send message
|
||||
|
||||
db.find({
|
||||
selector: {
|
||||
_id: id,
|
||||
},
|
||||
}).then(function (result){
|
||||
console.log(result)
|
||||
let obj = result.docs[0]
|
||||
console.log(obj)
|
||||
obj.attempt += 1
|
||||
databaseUpsert(obj.uuid, "attempt", obj.attempt);
|
||||
updateUnsortedChatListEntry(obj.uuid, "attempt", obj.attempt);
|
||||
sendMessage(obj)
|
||||
}).catch(function (err) {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
|
||||
// delete a message from databse and gui
|
||||
|
@ -403,6 +393,7 @@ if (typeof dxcallsign !== 'undefined'){
|
|||
if(chat.sorted_chat_list[dxcallsign][key].is_new){
|
||||
item_array.push(chat.sorted_chat_list[dxcallsign][key])
|
||||
new_counter += 1
|
||||
|
||||
}
|
||||
total_counter += 1
|
||||
}
|
||||
|
@ -612,6 +603,8 @@ export function deleteChatByCallsign(callsign) {
|
|||
deleteFromDatabaseByCallsign(callsign);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function deleteFromDatabaseByCallsign(callsign) {
|
||||
db.find({
|
||||
selector: {
|
||||
|
|
|
@ -595,8 +595,36 @@ function sendFile(
|
|||
}
|
||||
|
||||
// Send Message
|
||||
export function sendMessage(dxcallsign, data, checksum, uuid, command) {
|
||||
data = btoa_FD(
|
||||
export function sendMessage(obj) {
|
||||
|
||||
let dxcallsign = obj.dxcallsign
|
||||
let checksum = obj.checksum
|
||||
let uuid = obj.uuid
|
||||
let command = obj.command
|
||||
|
||||
let filename = Object.keys(obj._attachments)[0]
|
||||
//let filetype = filename.split(".")[1]
|
||||
let filetype = obj._attachments[filename].content_type
|
||||
let file = obj._attachments[filename].data
|
||||
|
||||
//console.log(obj._attachments)
|
||||
//console.log(filename)
|
||||
//console.log(filetype)
|
||||
//console.log(file)
|
||||
|
||||
|
||||
let data_with_attachment =
|
||||
obj.timestamp +
|
||||
split_char +
|
||||
obj.msg +
|
||||
split_char +
|
||||
filename +
|
||||
split_char +
|
||||
filetype +
|
||||
split_char +
|
||||
file;
|
||||
|
||||
let data = btoa_FD(
|
||||
"m" +
|
||||
split_char +
|
||||
command +
|
||||
|
@ -605,7 +633,7 @@ export function sendMessage(dxcallsign, data, checksum, uuid, command) {
|
|||
split_char +
|
||||
uuid +
|
||||
split_char +
|
||||
data,
|
||||
data_with_attachment,
|
||||
);
|
||||
|
||||
// TODO: REMOVE mode and frames from TNC!
|
||||
|
|
|
@ -81,5 +81,6 @@ export const useChatStore = defineStore("chatStore", () => {
|
|||
beaconLabelArray,
|
||||
unsorted_beacon_list,
|
||||
sorted_beacon_list,
|
||||
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue