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";
//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";
@ -859,27 +859,41 @@ export function newMessageReceived(message, 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 = {
command: "msg",
hmac_signed: protocol["hmac_signed"],
hmac_signed: false,
percent: 100,
bytesperminute: protocol["bytesperminute"],
bytesperminute: 0,
is_new: true,
_id: message[3],
timestamp: message[4],
dxcallsign: protocol["dxcallsign"],
dxgrid: protocol["dxgrid"],
dxcallsign: protocol["dxcall"],
dxgrid: '',
msg: message[5],
checksum: message[2],
type: protocol["status"],
status: protocol["status"],
type: 'received',
status: 'received',
attempt: 1,
uuid: message[3],
duration: protocol["duration"],
nacks: protocol["nacks"],
speed_list: protocol["speed_list"],
duration: 0,
nacks: 0,
speed_list: [],
_attachments: {
[message[6]]: {
content_type: message[7],

View file

@ -82,10 +82,6 @@ export function eventDispatcher(data) {
5000,
);
return;
default:
console.warn("Unknown event message received:");
console.warn(data);
break;
}
var message = "";
@ -152,7 +148,7 @@ export function eventDispatcher(data) {
if (data["arq-transfer-inbound"]) {
switch (data["arq-transfer-inbound"].state) {
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);
return;
@ -167,11 +163,15 @@ export function eventDispatcher(data) {
return;
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;
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;
case "ABORTED":