From 3d2a3dedd89c2f2f83f60f107a1049f41138a64b Mon Sep 17 00:00:00 2001 From: 1aerostorm Date: Mon, 30 Sep 2024 22:05:41 +0300 Subject: [PATCH] Test --- src/utils/NotifyApiClient.js | 17 ++++++++++++++--- src/utils/ServerApiClient.js | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/utils/NotifyApiClient.js b/src/utils/NotifyApiClient.js index 2a044df3..d998273c 100644 --- a/src/utils/NotifyApiClient.js +++ b/src/utils/NotifyApiClient.js @@ -62,10 +62,19 @@ async function connectNotifyWs() { notifyWs.addEventListener('open', () => { notifyWs.isOpen = true clearTimeout(timeout) + setInterval(() => { + console.log('NOTW', notifyWs.readyState) + //notifyWs.send('_heartbeat') + }, 1000) resolve() }) + notifyWs.addEventListener('error', () => { + alert('NOTW close') + }) + notifyWs.addEventListener('сlose', () => { + alert('NOTW close') if (!notifyWs.isOpen) { clearTimeout(timeout) const err = new Error('notifyWs - cannot connect') @@ -200,7 +209,7 @@ export async function notificationSubscribe(account, scopes = 'message,donate_ms throw new Error('Cannot subscribe'); } -export async function notificationSubscribeWs(account, callback, scopes = 'message,donate_msgs') { +export async function notificationSubscribeWs(account, callback, scopes = 'message,donate_msgs', sidKey = '__subscriber_id') { if (!notifyWsAvailable()) return null const xSession = notifySession() return await new Promise(async (resolve, reject) => { @@ -213,6 +222,7 @@ export async function notificationSubscribeWs(account, callback, scopes = 'messa reject(err) return } + window[sidKey] = res.subscriber_id resolve(res) }, { event: 'queue', callback}) }) @@ -341,12 +351,13 @@ export async function sendOffchainMessage(op) { } } -if (process.env.BROWSER) { +//if (process.env.BROWSER) { window.getNotifications = getNotifications; window.markNotificationRead = markNotificationRead; window.notificationSubscribe = notificationSubscribe; + window.notificationSubscribeWs = notificationSubscribeWs window.notificationUnsubscribe = notificationUnsubscribe; window.notificationShallowUnsubscribe = notificationShallowUnsubscribe window.notificationTake = notificationTake; window.queueWatch = queueWatch -} +//} diff --git a/src/utils/ServerApiClient.js b/src/utils/ServerApiClient.js index 858eb465..7e8d04c8 100644 --- a/src/utils/ServerApiClient.js +++ b/src/utils/ServerApiClient.js @@ -3,7 +3,7 @@ import { fetchEx } from 'golos-lib-js/lib/utils' export function getHost() { const { location, } = window; if (process.env.NODE_ENV === 'development') { - return location.protocol + '//'+ location.hostname + ':8089'; + return location.protocol + '//'+ location.hostname + ':8088'; } return location.origin; }