anear-js-api 0.3.19 → 0.3.22
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.
|
@@ -102,7 +102,7 @@ class AnearMessaging {
|
|
|
102
102
|
timerStarter = () => timer.start(timeoutMsecs)
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
logger.debug(`
|
|
105
|
+
logger.debug(`ensureParticipantTimer(timeRemaining: ${timeRemaining})`)
|
|
106
106
|
|
|
107
107
|
return [timerStarter, timeRemaining]
|
|
108
108
|
}
|
|
@@ -128,6 +128,11 @@ class AnearMessaging {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
resetAllParticipantTimers() {
|
|
132
|
+
// turns off all participant timers
|
|
133
|
+
Object.entries(this.participantTimers).forEach(timer => timer.reset())
|
|
134
|
+
}
|
|
135
|
+
|
|
131
136
|
interruptParticipantTimer(participantId) {
|
|
132
137
|
const timer = this.participantTimers[participantId]
|
|
133
138
|
|
|
@@ -568,12 +573,15 @@ class AnearMessaging {
|
|
|
568
573
|
|
|
569
574
|
async publishEventSpectatorsMessage(anearEvent, css, message, messageType = PublicDisplayMessageType) {
|
|
570
575
|
const channel = this.eventChannels[anearEvent.id].spectators
|
|
571
|
-
const payload = {
|
|
572
|
-
css: css,
|
|
573
|
-
content: message
|
|
574
|
-
}
|
|
575
576
|
|
|
576
|
-
await this.
|
|
577
|
+
await this.publishMessage(
|
|
578
|
+
channel,
|
|
579
|
+
messageType,
|
|
580
|
+
css,
|
|
581
|
+
message,
|
|
582
|
+
0,
|
|
583
|
+
0
|
|
584
|
+
)
|
|
577
585
|
}
|
|
578
586
|
|
|
579
587
|
setMultipleParticipantTimers(anearEvent, participants, timeoutMsecs) {
|
package/lib/models/AnearEvent.js
CHANGED
|
@@ -233,6 +233,10 @@ class AnearEvent extends JsonApiResource {
|
|
|
233
233
|
this.anearStateMachine.sendTimeoutEvent({ participant })
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
+
cancelParticipantTimers() {
|
|
237
|
+
this.messaging.resetAllParticipantTimers()
|
|
238
|
+
}
|
|
239
|
+
|
|
236
240
|
async eventBroadcast(message) {
|
|
237
241
|
await this.eventBroadcastEventCallback(message)
|
|
238
242
|
}
|
|
@@ -252,6 +256,7 @@ class AnearEvent extends JsonApiResource {
|
|
|
252
256
|
try {
|
|
253
257
|
const responseAttributes = await this.messaging.api.transitionEvent(this.id, eventName)
|
|
254
258
|
const newState = responseAttributes.state
|
|
259
|
+
this.attributes.state = newState
|
|
255
260
|
await this.messaging.publishEventTransitionMessage(this, newState)
|
|
256
261
|
} catch(err) {
|
|
257
262
|
logger.error(`AnearEvent: transitionEvent error: ${err}`)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anear-js-api",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.22",
|
|
4
4
|
"description": "Javascript Developer API for Anear Apps",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -17,17 +17,17 @@
|
|
|
17
17
|
},
|
|
18
18
|
"homepage": "https://github.com/machvee/anear-js-api#readme",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"ably": "^1.2.
|
|
20
|
+
"ably": "^1.2.22",
|
|
21
21
|
"async-mutex": "^0.3.2",
|
|
22
22
|
"async-redis": "^2.0.0",
|
|
23
23
|
"cross-fetch": "^3.1.5",
|
|
24
|
-
"qs": "^6.10.
|
|
24
|
+
"qs": "^6.10.3",
|
|
25
25
|
"simple-node-logger": "^21.8.12",
|
|
26
|
-
"xstate": "^4.
|
|
26
|
+
"xstate": "^4.32.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"fakeredis": "^2.0.0",
|
|
30
30
|
"jest": "^26.6.3",
|
|
31
|
-
"node-notifier": "
|
|
31
|
+
"node-notifier": "^10.0.1"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/tests/AnearEvent.test.js
CHANGED
|
@@ -358,3 +358,23 @@ test('can update state machine context via Action events', async () => {
|
|
|
358
358
|
await t.participantClose(p2)
|
|
359
359
|
await t.remove()
|
|
360
360
|
})
|
|
361
|
+
|
|
362
|
+
test('can reset All ParticipantTimers', async () => {
|
|
363
|
+
const t = newTestEvent(false)
|
|
364
|
+
const p1 = new TestPlayer(chatParticipant1)
|
|
365
|
+
const p2 = new TestPlayer(chatParticipant2)
|
|
366
|
+
|
|
367
|
+
const resetMock = jest.spyOn(MessagingStub, "resetAllParticipantTimers");
|
|
368
|
+
|
|
369
|
+
await t.participantEnter(p1)
|
|
370
|
+
await t.participantEnter(p2)
|
|
371
|
+
await t.persist()
|
|
372
|
+
|
|
373
|
+
t.cancelParticipantTimers()
|
|
374
|
+
|
|
375
|
+
expect(resetMock).toHaveBeenCalledTimes(1)
|
|
376
|
+
|
|
377
|
+
await t.participantClose(p1)
|
|
378
|
+
await t.participantClose(p2)
|
|
379
|
+
await t.remove()
|
|
380
|
+
})
|