Skip to content

Commit

Permalink
ULMS-3222 Deleted unused entity events
Browse files Browse the repository at this point in the history
  • Loading branch information
dkvovik committed Aug 1, 2024
1 parent 6800afd commit fae9e6f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 52 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ulms/api-clients",
"version": "7.9.8",
"version": "7.9.9-dev.0-ULMS-3222",
"description": "JavaScript API clients for ULMS platform",
"keywords": [],
"homepage": "https://github.com/foxford/ulms-api-clients-js#readme",
Expand Down
12 changes: 0 additions & 12 deletions src/broker.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@ const entityEventsEnum = {
CLASSROOM_ENTER: 'classroom.enter',
CLASSROOM_LEAVE: 'classroom.leave',
CLASSROOM_UPDATE: 'classroom.update',
CONFERENCE_ROOM_CLOSE: 'conference_room.close',
CONFERENCE_ROOM_ENTER: 'conference_room.enter',
CONFERENCE_ROOM_LEAVE: 'conference_room.leave',
EVENT_CREATE: 'event.create',
EVENT_ROOM_ENTER: 'event_room.enter',
EVENT_ROOM_LEAVE: 'event_room.leave',
EVENT_ROOM_UPDATE: 'event_room.update',
GROUP_UPDATE: 'video_group.update',
RTC_STREAM_AGENT_SPEAKING: 'rtc_stream.agent_speaking',
RTC_STREAM_UPDATE: 'rtc_stream.update',
Expand All @@ -52,13 +46,7 @@ class Broker {
* CLASSROOM_ENTER: string,
* CLASSROOM_LEAVE: string,
* CLASSROOM_UPDATE: string,
* CONFERENCE_ROOM_CLOSE: string,
* CONFERENCE_ROOM_ENTER: string,
* CONFERENCE_ROOM_LEAVE: string,
* EVENT_CREATE: string,
* EVENT_ROOM_ENTER: string,
* EVENT_ROOM_LEAVE: string,
* EVENT_ROOM_UPDATE: string,
* GROUP_UPDATE: string,
* RTC_STREAM_AGENT_SPEAKING: string,
* RTC_STREAM_UPDATE: string,
Expand Down
39 changes: 2 additions & 37 deletions src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,32 +69,9 @@ export async function enterServiceRoom(
) {
const backoff = new Backoff()
const isTransportConnected = () => client.mqtt.connected
let enterEventRoomSuccess = false
let enterConferenceRoomSuccess = false
let enterClassroomSuccess = false
let response

const handlerEnterEventRoom = (event) => {
if (event.data.agent_id === id) {
console.log('[handlerEnterEventRoom] enterEventRoomSuccess')
enterEventRoomSuccess = true

client.off(Broker.events.EVENT_ROOM_ENTER, handlerEnterEventRoom)
}
}

const handlerEnterConferenceRoom = (event) => {
if (event.data.agent_id === id) {
console.log('[handlerEnterConferenceRoom] enterConferenceRoomSuccess')
enterConferenceRoomSuccess = true

client.off(
Broker.events.CONFERENCE_ROOM_ENTER,
handlerEnterConferenceRoom,
)
}
}

const handlerEnterClassroom = (event) => {
if (event.data.agent_id === id) {
console.log('[handlerEnterClassroom] enterClassroomSuccess')
Expand All @@ -104,8 +81,6 @@ export async function enterServiceRoom(
}
}

client.on(Broker.events.EVENT_ROOM_ENTER, handlerEnterEventRoom)
client.on(Broker.events.CONFERENCE_ROOM_ENTER, handlerEnterConferenceRoom)
client.on(Broker.events.CLASSROOM_ENTER, handlerEnterClassroom)

try {
Expand All @@ -122,28 +97,18 @@ export async function enterServiceRoom(
throw new Error('MQTT client disconnected')
}

if (
enterClassroomSuccess ||
(enterEventRoomSuccess && enterConferenceRoomSuccess)
)
break
if (enterClassroomSuccess) break

// eslint-disable-next-line no-await-in-loop
await sleep(backoff.value)

backoff.next()

if (
enterClassroomSuccess ||
(enterEventRoomSuccess && enterConferenceRoomSuccess)
)
break
if (enterClassroomSuccess) break

trackEvent('Debug', `${serviceName}.Subscription.Retry`)
}
} catch (error) {
client.off(Broker.events.EVENT_ROOM_ENTER, handlerEnterEventRoom)
client.off(Broker.events.CONFERENCE_ROOM_ENTER, handlerEnterConferenceRoom)
client.off(Broker.events.CLASSROOM_ENTER, handlerEnterClassroom)

backoff.reset()
Expand Down

0 comments on commit fae9e6f

Please sign in to comment.