anear-js-api 0.3.23 → 0.3.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -312,6 +312,14 @@ class AnearMessaging {
|
|
|
312
312
|
)
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
+
async getSpectatorCount(anearEvent) {
|
|
316
|
+
if (!anearEvent.allowsSpectators()) return 0
|
|
317
|
+
|
|
318
|
+
const channel = this.eventChannels[anearEvent.id].spectators
|
|
319
|
+
const members = await channel.presence.get()
|
|
320
|
+
return members.length
|
|
321
|
+
}
|
|
322
|
+
|
|
315
323
|
async setupActionsChannel(anearEvent) {
|
|
316
324
|
const actionsChannel = this.getChannel(anearEvent.actionsChannelName())
|
|
317
325
|
|
package/lib/models/AnearEvent.js
CHANGED
|
@@ -120,6 +120,10 @@ class AnearEvent extends JsonApiResource {
|
|
|
120
120
|
return !this.hasFlag("no_spectators")
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
async spectatorCount() {
|
|
124
|
+
return await this.messaging.getSpectatorCount(this)
|
|
125
|
+
}
|
|
126
|
+
|
|
123
127
|
async createdEventCallback(participantCreator) {
|
|
124
128
|
// You may implement createdEventCallback() in your AnearEvent sub-class
|
|
125
129
|
}
|
|
@@ -281,10 +285,12 @@ class AnearEvent extends JsonApiResource {
|
|
|
281
285
|
}
|
|
282
286
|
|
|
283
287
|
async transitionClosed() {
|
|
288
|
+
this.cancelParticipantTimers()
|
|
284
289
|
await this.transitionNextNext()
|
|
285
290
|
}
|
|
286
291
|
|
|
287
292
|
async transitionCanceled() {
|
|
293
|
+
this.cancelParticipantTimers()
|
|
288
294
|
await this.transitionEvent('cancel')
|
|
289
295
|
}
|
|
290
296
|
|