|
7 | 7 | Object.defineProperty(exports, "__esModule", { value: true }); |
8 | 8 | exports.HeartbeatingState = void 0; |
9 | 9 | const events_1 = require("../events"); |
10 | | -const heartbeat_inactive_1 = require("./heartbeat_inactive"); |
11 | | -const heartbeat_cooldown_1 = require("./heartbeat_cooldown"); |
12 | | -const heartbeat_stopped_1 = require("./heartbeat_stopped"); |
13 | | -const heartbeat_failed_1 = require("./heartbeat_failed"); |
14 | 10 | const effects_1 = require("../effects"); |
15 | | -const state_1 = require("../../core/state"); |
| 11 | +const instances_1 = require("./instances"); |
| 12 | +Object.defineProperty(exports, "HeartbeatingState", { enumerable: true, get: function () { return instances_1.HeartbeatingState; } }); |
16 | 13 | /** |
17 | 14 | * Heartbeating state module. |
18 | 15 | * |
19 | 16 | * State in which Presence Event Engine send heartbeat REST API call. |
20 | 17 | * |
21 | 18 | * @internal |
22 | 19 | */ |
23 | | -exports.HeartbeatingState = new state_1.State('HEARTBEATING'); |
24 | | -exports.HeartbeatingState.onEnter((context) => (0, effects_1.heartbeat)(context.channels, context.groups)); |
25 | | -exports.HeartbeatingState.onExit(() => effects_1.heartbeat.cancel); |
26 | | -exports.HeartbeatingState.on(events_1.heartbeatSuccess.type, (context, event) => heartbeat_cooldown_1.HeartbeatCooldownState.with({ channels: context.channels, groups: context.groups }, [ |
| 20 | +instances_1.HeartbeatingState.onEnter((context) => (0, effects_1.heartbeat)(context.channels, context.groups)); |
| 21 | +instances_1.HeartbeatingState.onExit(() => effects_1.heartbeat.cancel); |
| 22 | +instances_1.HeartbeatingState.on(events_1.heartbeatSuccess.type, (context, event) => instances_1.HeartbeatCooldownState.with({ channels: context.channels, groups: context.groups }, [ |
27 | 23 | (0, effects_1.emitStatus)(Object.assign({}, event.payload)), |
28 | 24 | ])); |
29 | | -exports.HeartbeatingState.on(events_1.joined.type, (context, event) => exports.HeartbeatingState.with({ |
| 25 | +instances_1.HeartbeatingState.on(events_1.joined.type, (context, event) => instances_1.HeartbeatingState.with({ |
30 | 26 | channels: [...context.channels, ...event.payload.channels.filter((channel) => !context.channels.includes(channel))], |
31 | 27 | groups: [...context.groups, ...event.payload.groups.filter((group) => !context.groups.includes(group))], |
32 | 28 | })); |
33 | | -exports.HeartbeatingState.on(events_1.left.type, (context, event) => { |
34 | | - return exports.HeartbeatingState.with({ |
| 29 | +instances_1.HeartbeatingState.on(events_1.left.type, (context, event) => { |
| 30 | + return instances_1.HeartbeatingState.with({ |
35 | 31 | channels: context.channels.filter((channel) => !event.payload.channels.includes(channel)), |
36 | 32 | groups: context.groups.filter((group) => !event.payload.groups.includes(group)), |
37 | 33 | }, [(0, effects_1.leave)(event.payload.channels, event.payload.groups)]); |
38 | 34 | }); |
39 | | -exports.HeartbeatingState.on(events_1.heartbeatFailure.type, (context, event) => heartbeat_failed_1.HeartbeatFailedState.with(Object.assign({}, context), [ |
| 35 | +instances_1.HeartbeatingState.on(events_1.heartbeatFailure.type, (context, event) => instances_1.HeartbeatFailedState.with(Object.assign({}, context), [ |
40 | 36 | ...(event.payload.status ? [(0, effects_1.emitStatus)(Object.assign({}, event.payload.status))] : []), |
41 | 37 | ])); |
42 | | -exports.HeartbeatingState.on(events_1.disconnect.type, (context, event) => heartbeat_stopped_1.HeartbeatStoppedState.with({ channels: context.channels, groups: context.groups }, [ |
| 38 | +instances_1.HeartbeatingState.on(events_1.disconnect.type, (context, event) => instances_1.HeartbeatStoppedState.with({ channels: context.channels, groups: context.groups }, [ |
43 | 39 | ...(!event.payload.isOffline ? [(0, effects_1.leave)(context.channels, context.groups)] : []), |
44 | 40 | ])); |
45 | | -exports.HeartbeatingState.on(events_1.leftAll.type, (context, event) => heartbeat_inactive_1.HeartbeatInactiveState.with(undefined, [ |
| 41 | +instances_1.HeartbeatingState.on(events_1.leftAll.type, (context, event) => instances_1.HeartbeatInactiveState.with(undefined, [ |
46 | 42 | ...(!event.payload.isOffline ? [(0, effects_1.leave)(context.channels, context.groups)] : []), |
47 | 43 | ])); |
0 commit comments