Skip to content

Commit

Permalink
fixup! add handler for speaking signals of participants and frontend …
Browse files Browse the repository at this point in the history
…support

Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Aug 7, 2023
1 parent 773c86b commit c26d71d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/store/participantsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const getters = {
*/
getParticipantSpeakingInformation: (state) => (token, sessionIds) => {
if (!state.speaking[token]) {
return false
return undefined
}

// look for existing sessionId in the store
Expand Down Expand Up @@ -382,7 +382,8 @@ const mutations = {
},

/**
* Purge the speaking information (when the call ends).
* Purge the speaking information for recent call
* when the call ends or local participant leaves call.
*
* @param {object} state - current store state.
* @param {object} data - the wrapping object.
Expand Down
16 changes: 9 additions & 7 deletions src/utils/SignalingSpeakingHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@
*/

/**
* Helper to handle signaling messages for speaking / speakingStopped notifications.
* Helper to handle speaking status changes notified by call models.
*
* The store is updated when local or remote participants change their speaking status.
*
* It is expected that the speaking status of participant will be
* modified only when the current conversation is joined and call is started.
*
*/
export default class SignalingSpeakingHandler {

Expand All @@ -37,7 +35,7 @@ export default class SignalingSpeakingHandler {
#localMediaModel
#callParticipantCollection

// Methods (bounded to have access to 'this')
// Methods (bound to have access to 'this')
#handleAddParticipantBound
#handleRemoveParticipantBound
#handleLocalSpeakingBound
Expand All @@ -62,7 +60,6 @@ export default class SignalingSpeakingHandler {

/**
* Destroy a handler, remove all listeners, purge the speaking state from store
*
*/
destroy() {
this.#localMediaModel.off('change:speaking', this.#handleLocalSpeakingBound)
Expand All @@ -71,11 +68,16 @@ export default class SignalingSpeakingHandler {
this.#callParticipantCollection.off('add', this.#handleAddParticipantBound)
this.#callParticipantCollection.off('remove', this.#handleRemoveParticipantBound)

this.#callParticipantCollection.callParticipantModels.forEach(callParticipantModel => {
callParticipantModel.off('change:speaking', this.#handleSpeakingBound)
callParticipantModel.off('change:stoppedSpeaking', this.#handleSpeakingBound)
})

this.#store.dispatch('purgeSpeakingStore', { token: this.#store.getters.getToken() })
}

/**
* Add listeners for speaking signals on added participants model
* Add listeners for speaking status changes on added participants model
*
* @param {object} callParticipantCollection the collection of external participant models
* @param {object} callParticipantModel the added participant model
Expand All @@ -86,7 +88,7 @@ export default class SignalingSpeakingHandler {
}

/**
* Remove listeners for speaking signals on removed participants model
* Remove listeners for speaking status changes on removed participants model
*
* @param {object} callParticipantCollection the collection of external participant models
* @param {object} callParticipantModel the removed participant model
Expand Down

0 comments on commit c26d71d

Please sign in to comment.