Minor fixes in websockets.ts

This commit is contained in:
Sosthene 2024-12-17 11:51:18 +01:00
parent a5e1d0cd79
commit 237331c67f

View File

@ -26,7 +26,6 @@ export async function initWebsocket(url: string) {
(async () => { (async () => {
if (typeof msgData === 'string') { if (typeof msgData === 'string') {
try { try {
const feeRate = 0.0001;
const parsedMessage = JSON.parse(msgData); const parsedMessage = JSON.parse(msgData);
const services = await Services.getInstance(); const services = await Services.getInstance();
switch (parsedMessage.flag) { switch (parsedMessage.flag) {
@ -65,7 +64,7 @@ export function sendMessage(flag: AnkFlag, message: string): void {
flag: flag, flag: flag,
content: message, content: message,
}; };
console.log('Sending message:', JSON.stringify(networkMessage)); console.log('Sending message of type:', flag);
ws.send(JSON.stringify(networkMessage)); ws.send(JSON.stringify(networkMessage));
} else { } else {
console.error('WebSocket is not open. ReadyState:', ws.readyState); console.error('WebSocket is not open. ReadyState:', ws.readyState);
@ -77,11 +76,6 @@ export function getUrl(): string {
return ws.url; return ws.url;
} }
export function sendNormalMessage(message: string) {
ws.send(message);
console.log('Sending message:', JSON.stringify(message));
}
// Method to close the WebSocket connection // Method to close the WebSocket connection
export function close(): void { export function close(): void {
ws.close(); ws.close();