adapted message system to new server

This commit is contained in:
DJ2LS 2024-01-05 16:52:16 +01:00
parent 7f81de7ea2
commit a2c53b5496
2 changed files with 31 additions and 17 deletions

View file

@ -18,7 +18,7 @@ import { settingsStore as settings } from "../store/settingsStore.js";
import { displayToast } from "./popupHandler.js"; import { displayToast } from "./popupHandler.js";
//const FD = require("./src/js/freedata.js"); //const FD = require("./src/js/freedata.js");
import { btoa_FD, sortByProperty } from "./freedata.js"; import { atob_FD, btoa_FD, sortByProperty, sortByPropertyDesc } from "./freedata.js";
import { sendModemARQRaw } from "../js/api.js"; import { sendModemARQRaw } from "../js/api.js";
@ -859,27 +859,41 @@ export function newMessageReceived(message, protocol) {
*/ */
console.log(protocol); console.log(protocol);
var encoded_data = atob_FD(message);
var splitted_data = encoded_data.split(split_char);
// new message received
if (splitted_data[0] == "m") {
console.log(splitted_data);
message = splitted_data;
} else {
return;
}
let newChatObj: messageDefaultObject = { let newChatObj: messageDefaultObject = {
command: "msg", command: "msg",
hmac_signed: protocol["hmac_signed"], hmac_signed: false,
percent: 100, percent: 100,
bytesperminute: protocol["bytesperminute"], bytesperminute: 0,
is_new: true, is_new: true,
_id: message[3], _id: message[3],
timestamp: message[4], timestamp: message[4],
dxcallsign: protocol["dxcallsign"], dxcallsign: protocol["dxcall"],
dxgrid: protocol["dxgrid"], dxgrid: '',
msg: message[5], msg: message[5],
checksum: message[2], checksum: message[2],
type: protocol["status"], type: 'received',
status: protocol["status"], status: 'received',
attempt: 1, attempt: 1,
uuid: message[3], uuid: message[3],
duration: protocol["duration"], duration: 0,
nacks: protocol["nacks"], nacks: 0,
speed_list: protocol["speed_list"], speed_list: [],
_attachments: { _attachments: {
[message[6]]: { [message[6]]: {
content_type: message[7], content_type: message[7],

View file

@ -82,10 +82,6 @@ export function eventDispatcher(data) {
5000, 5000,
); );
return; return;
default:
console.warn("Unknown event message received:");
console.warn(data);
break;
} }
var message = ""; var message = "";
@ -152,7 +148,7 @@ export function eventDispatcher(data) {
if (data["arq-transfer-inbound"]) { if (data["arq-transfer-inbound"]) {
switch (data["arq-transfer-inbound"].state) { switch (data["arq-transfer-inbound"].state) {
case "NEW": case "NEW":
message = `Type: ${data.type}, Session ID: ${data["arq-transfer-outbound"].session_id}, DXCall: ${data["arq-transfer-outbound"].dxcall}, State: ${data["arq-transfer-outbound"].state}`; message = `Type: ${data.type}, Session ID: ${data["arq-transfer-inbound"].session_id}, DXCall: ${data["arq-transfer-inbound"].dxcall}, State: ${data["arq-transfer-inbound"].state}`;
displayToast("info", "bi-info-circle", message, 5000); displayToast("info", "bi-info-circle", message, 5000);
return; return;
@ -167,11 +163,15 @@ export function eventDispatcher(data) {
return; return;
case "BURST_REPLY_SENT": case "BURST_REPLY_SENT":
console.log("state BURST_REPLY_SENT needs to be implemented"); message = `Type: ${data.type}, Session ID: ${data["arq-transfer-inbound"].session_id}, DXCall: ${data["arq-transfer-inbound"].dxcall}, Received Bytes: ${data["arq-transfer-inbound"].received_bytes}/${data["arq-transfer-inbound"].total_bytes}, State: ${data["arq-transfer-inbound"].state}`;
displayToast("info", "bi-info-circle", message, 5000);
return; return;
case "ENDED": case "ENDED":
console.log("state ENDED needs to be implemented"); message = `Type: ${data.type}, Session ID: ${data["arq-transfer-inbound"].session_id}, DXCall: ${data["arq-transfer-inbound"].dxcall}, Received Bytes: ${data["arq-transfer-inbound"].received_bytes}/${data["arq-transfer-inbound"].total_bytes}, State: ${data["arq-transfer-inbound"].state}`;
displayToast("info", "bi-info-circle", message, 5000);
// Forward data to chat module
newMessageReceived(data["arq-transfer-inbound"].data, data["arq-transfer-inbound"]);
return; return;
case "ABORTED": case "ABORTED":