From 752530d9a5d6806be20c3e7e1bcee53b4546f63a Mon Sep 17 00:00:00 2001 From: Vladimir Berdnikov Date: Wed, 19 Jun 2024 10:01:57 +0300 Subject: [PATCH] removed unused subscribeWithNotification method --- package-lock.json | 4 +-- package.json | 2 +- src/common.js | 75 ++--------------------------------------------- 3 files changed, 5 insertions(+), 76 deletions(-) diff --git a/package-lock.json b/package-lock.json index 489bc8c..52b2769 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@ulms/api-clients", - "version": "7.8.1-dev.5-ULMS-3116", + "version": "7.8.1-dev.6-ULMS-3116", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@ulms/api-clients", - "version": "7.8.1-dev.5-ULMS-3116", + "version": "7.8.1-dev.6-ULMS-3116", "license": "MIT", "dependencies": { "axios": "1.6.2", diff --git a/package.json b/package.json index d9838e7..202a507 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ulms/api-clients", - "version": "7.8.1-dev.5-ULMS-3116", + "version": "7.8.1-dev.6-ULMS-3116", "description": "JavaScript API clients for ULMS platform", "keywords": [], "homepage": "https://github.com/foxford/ulms-api-clients-js#readme", diff --git a/src/common.js b/src/common.js index 0ab5947..c43dba6 100644 --- a/src/common.js +++ b/src/common.js @@ -74,9 +74,8 @@ export async function enterServiceRoom( let response const handlerEnterEventRoom = (event) => { - console.log('[handlerEnterEventRoom] handler', event) if (event.data.agent_id === id) { - console.log('[handlerEnterEventRoom] enterEventRoomSuccess = true') + console.log('[handlerEnterEventRoom] enterEventRoomSuccess') enterEventRoomSuccess = true client.off(Broker.events.EVENT_ROOM_ENTER, handlerEnterEventRoom) @@ -84,11 +83,8 @@ export async function enterServiceRoom( } const handlerEnterConferenceRoom = (event) => { - console.log('[handlerEnterConferenceRoom] handler', event) if (event.data.agent_id === id) { - console.log( - '[handlerEnterConferenceRoom] enterConferenceRoomSuccess = true', - ) + console.log('[handlerEnterConferenceRoom] enterConferenceRoomSuccess') enterConferenceRoomSuccess = true client.off( @@ -184,70 +180,3 @@ export const timeout = async (delay) => { return promise } - -export async function subscribeWithNotification( - client, - httpClient, - eventName, - roomId, - id, - label, - trackEvent, - serviceName, -) { - const backoff = new Backoff() - const isTransportConnected = () => client.mqtt.connected - let subscribeRoomSuccess = false - let response - - const handler = (event) => { - if (event.data.agent_id === id) { - console.log( - '[subscribeWithNotification] subscribeRoomSuccess = true', - eventName, - ) - subscribeRoomSuccess = true - - client.off(eventName, handler) - } - } - - client.on(eventName, handler) - - try { - // eslint-disable-next-line no-constant-condition - while (true) { - if (!isTransportConnected()) { - throw new Error('MQTT client disconnected') - } - - // eslint-disable-next-line no-await-in-loop - response = await httpClient.subscribeRoom(roomId, label) - - if (!isTransportConnected()) { - throw new Error('MQTT client disconnected') - } - - if (subscribeRoomSuccess) break - - // eslint-disable-next-line no-await-in-loop - await sleep(backoff.value) - - backoff.next() - - if (subscribeRoomSuccess) break - - trackEvent('Debug', `${serviceName}.Subscription.Retry`) - } - } catch (error) { - client.off(eventName, handler) - - backoff.reset() - - throw error - } - - backoff.reset() - - return response -}