From 090a7756e8bfb4c8bcc56633cf446944a7e334eb Mon Sep 17 00:00:00 2001 From: Vitaliy Sulimenko Date: Wed, 16 Oct 2024 17:24:39 +0400 Subject: [PATCH] ++ --- js/jetPack.js | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/js/jetPack.js b/js/jetPack.js index 38ea6a6..4083024 100644 --- a/js/jetPack.js +++ b/js/jetPack.js @@ -26,8 +26,8 @@ // Main JetPack class definition class JetPack { // Private params - #userId = '' - // #userId = '808958531' + // #userId = '' + #userId = '808958531' #peer = null #peerID = null #conn = null @@ -57,6 +57,8 @@ // Set data if (userParams) { this.#userId = userParams.id + + document.getElementById('ddd').innerText = this.#userId } } } @@ -116,6 +118,7 @@ // Create connection to jetWallet const intervalId = setInterval(() => { + // Save connection this.#conn = this.#peer.connect(`jw-${BOT_ID}-${this.#userId}`) // Successful connection @@ -129,24 +132,19 @@ // Processing data receipt this.#conn.on('data', data => { - try { - // Check the type of received data - if (data.type === 'address') { - // Save data - this.#jwAddress = data.address - - // Resolve the promise with true - resolve(true) - } else if (data.type === 'error') { - // Reject promise - reject(`Error received: ${data.message}`) - } else { - // Reject promise - reject('Unknown data type received.') - } - } catch (error) { + // Check the type of received data + if (data.type === 'address') { + // Save data + this.#jwAddress = data.address + + // Resolve the promise with true + resolve(true) + } else if (data.type === 'error') { + // Reject promise + reject(`Error received: ${data.message}`) + } else { // Reject promise - reject('Failed to parse incoming data.') + reject('Unknown data type received.') } })