@fluidframework/presence 2.91.0 → 2.93.0

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.
Files changed (259) hide show
  1. package/README.md +4 -4
  2. package/dist/alpha.d.ts +7 -5
  3. package/dist/beta.d.ts +6 -3
  4. package/dist/getPresence.d.ts +4 -9
  5. package/dist/getPresence.d.ts.map +1 -1
  6. package/dist/getPresence.js +6 -86
  7. package/dist/getPresence.js.map +1 -1
  8. package/dist/index.d.ts +4 -13
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +8 -8
  11. package/dist/index.js.map +1 -1
  12. package/dist/legacy.alpha.d.ts +7 -5
  13. package/dist/package.json +1 -15
  14. package/dist/public.d.ts +69 -0
  15. package/lib/alpha.d.ts +7 -5
  16. package/lib/beta.d.ts +6 -3
  17. package/lib/getPresence.d.ts +4 -9
  18. package/lib/getPresence.d.ts.map +1 -1
  19. package/lib/getPresence.js +6 -85
  20. package/lib/getPresence.js.map +1 -1
  21. package/lib/index.d.ts +4 -13
  22. package/lib/index.d.ts.map +1 -1
  23. package/lib/index.js +5 -4
  24. package/lib/index.js.map +1 -1
  25. package/lib/legacy.alpha.d.ts +7 -5
  26. package/lib/public.d.ts +69 -0
  27. package/package.json +31 -80
  28. package/dist/baseTypes.d.ts +0 -24
  29. package/dist/baseTypes.d.ts.map +0 -1
  30. package/dist/baseTypes.js +0 -7
  31. package/dist/baseTypes.js.map +0 -1
  32. package/dist/broadcastControls.d.ts +0 -37
  33. package/dist/broadcastControls.d.ts.map +0 -1
  34. package/dist/broadcastControls.js +0 -60
  35. package/dist/broadcastControls.js.map +0 -1
  36. package/dist/broadcastControlsTypes.d.ts +0 -38
  37. package/dist/broadcastControlsTypes.d.ts.map +0 -1
  38. package/dist/broadcastControlsTypes.js +0 -7
  39. package/dist/broadcastControlsTypes.js.map +0 -1
  40. package/dist/exposedInternalTypes.d.ts +0 -138
  41. package/dist/exposedInternalTypes.d.ts.map +0 -1
  42. package/dist/exposedInternalTypes.js +0 -19
  43. package/dist/exposedInternalTypes.js.map +0 -1
  44. package/dist/exposedUtilityTypes.d.ts +0 -108
  45. package/dist/exposedUtilityTypes.d.ts.map +0 -1
  46. package/dist/exposedUtilityTypes.js +0 -7
  47. package/dist/exposedUtilityTypes.js.map +0 -1
  48. package/dist/internalUtils.d.ts +0 -125
  49. package/dist/internalUtils.d.ts.map +0 -1
  50. package/dist/internalUtils.js +0 -99
  51. package/dist/internalUtils.js.map +0 -1
  52. package/dist/latestMapTypes.d.ts +0 -343
  53. package/dist/latestMapTypes.d.ts.map +0 -1
  54. package/dist/latestMapTypes.js +0 -7
  55. package/dist/latestMapTypes.js.map +0 -1
  56. package/dist/latestMapValueManager.d.ts +0 -52
  57. package/dist/latestMapValueManager.d.ts.map +0 -1
  58. package/dist/latestMapValueManager.js +0 -250
  59. package/dist/latestMapValueManager.js.map +0 -1
  60. package/dist/latestTypes.d.ts +0 -183
  61. package/dist/latestTypes.d.ts.map +0 -1
  62. package/dist/latestTypes.js +0 -7
  63. package/dist/latestTypes.js.map +0 -1
  64. package/dist/latestValueManager.d.ts +0 -10
  65. package/dist/latestValueManager.d.ts.map +0 -1
  66. package/dist/latestValueManager.js +0 -117
  67. package/dist/latestValueManager.js.map +0 -1
  68. package/dist/latestValueTypes.d.ts +0 -108
  69. package/dist/latestValueTypes.d.ts.map +0 -1
  70. package/dist/latestValueTypes.js +0 -7
  71. package/dist/latestValueTypes.js.map +0 -1
  72. package/dist/notificationsManager.d.ts +0 -27
  73. package/dist/notificationsManager.d.ts.map +0 -1
  74. package/dist/notificationsManager.js +0 -98
  75. package/dist/notificationsManager.js.map +0 -1
  76. package/dist/notificationsManagerTypes.d.ts +0 -144
  77. package/dist/notificationsManagerTypes.d.ts.map +0 -1
  78. package/dist/notificationsManagerTypes.js +0 -7
  79. package/dist/notificationsManagerTypes.js.map +0 -1
  80. package/dist/packageVersion.d.ts +0 -9
  81. package/dist/packageVersion.d.ts.map +0 -1
  82. package/dist/packageVersion.js +0 -12
  83. package/dist/packageVersion.js.map +0 -1
  84. package/dist/presence.d.ts +0 -229
  85. package/dist/presence.d.ts.map +0 -1
  86. package/dist/presence.js +0 -23
  87. package/dist/presence.js.map +0 -1
  88. package/dist/presenceDatastoreManager.d.ts +0 -149
  89. package/dist/presenceDatastoreManager.d.ts.map +0 -1
  90. package/dist/presenceDatastoreManager.js +0 -667
  91. package/dist/presenceDatastoreManager.js.map +0 -1
  92. package/dist/presenceManager.d.ts +0 -16
  93. package/dist/presenceManager.d.ts.map +0 -1
  94. package/dist/presenceManager.js +0 -140
  95. package/dist/presenceManager.js.map +0 -1
  96. package/dist/presenceStates.d.ts +0 -102
  97. package/dist/presenceStates.d.ts.map +0 -1
  98. package/dist/presenceStates.js +0 -231
  99. package/dist/presenceStates.js.map +0 -1
  100. package/dist/protocol.d.ts +0 -111
  101. package/dist/protocol.d.ts.map +0 -1
  102. package/dist/protocol.js +0 -20
  103. package/dist/protocol.js.map +0 -1
  104. package/dist/runtimeTypes.d.ts +0 -26
  105. package/dist/runtimeTypes.d.ts.map +0 -1
  106. package/dist/runtimeTypes.js +0 -7
  107. package/dist/runtimeTypes.js.map +0 -1
  108. package/dist/stateDatastore.d.ts +0 -56
  109. package/dist/stateDatastore.d.ts.map +0 -1
  110. package/dist/stateDatastore.js +0 -22
  111. package/dist/stateDatastore.js.map +0 -1
  112. package/dist/stateFactory.d.ts +0 -18
  113. package/dist/stateFactory.d.ts.map +0 -1
  114. package/dist/stateFactory.js +0 -23
  115. package/dist/stateFactory.js.map +0 -1
  116. package/dist/statesManagerTypes.d.ts +0 -27
  117. package/dist/statesManagerTypes.d.ts.map +0 -1
  118. package/dist/statesManagerTypes.js +0 -7
  119. package/dist/statesManagerTypes.js.map +0 -1
  120. package/dist/systemWorkspace.d.ts +0 -58
  121. package/dist/systemWorkspace.d.ts.map +0 -1
  122. package/dist/systemWorkspace.js +0 -265
  123. package/dist/systemWorkspace.js.map +0 -1
  124. package/dist/timerManager.d.ts +0 -37
  125. package/dist/timerManager.d.ts.map +0 -1
  126. package/dist/timerManager.js +0 -65
  127. package/dist/timerManager.js.map +0 -1
  128. package/dist/types.d.ts +0 -132
  129. package/dist/types.d.ts.map +0 -1
  130. package/dist/types.js +0 -7
  131. package/dist/types.js.map +0 -1
  132. package/dist/validatableTypes.d.ts +0 -69
  133. package/dist/validatableTypes.d.ts.map +0 -1
  134. package/dist/validatableTypes.js +0 -7
  135. package/dist/validatableTypes.js.map +0 -1
  136. package/dist/validatedGetter.d.ts +0 -18
  137. package/dist/validatedGetter.d.ts.map +0 -1
  138. package/dist/validatedGetter.js +0 -43
  139. package/dist/validatedGetter.js.map +0 -1
  140. package/dist/valueManager.d.ts +0 -15
  141. package/dist/valueManager.d.ts.map +0 -1
  142. package/dist/valueManager.js +0 -22
  143. package/dist/valueManager.js.map +0 -1
  144. package/lib/baseTypes.d.ts +0 -24
  145. package/lib/baseTypes.d.ts.map +0 -1
  146. package/lib/baseTypes.js +0 -6
  147. package/lib/baseTypes.js.map +0 -1
  148. package/lib/broadcastControls.d.ts +0 -37
  149. package/lib/broadcastControls.d.ts.map +0 -1
  150. package/lib/broadcastControls.js +0 -55
  151. package/lib/broadcastControls.js.map +0 -1
  152. package/lib/broadcastControlsTypes.d.ts +0 -38
  153. package/lib/broadcastControlsTypes.d.ts.map +0 -1
  154. package/lib/broadcastControlsTypes.js +0 -6
  155. package/lib/broadcastControlsTypes.js.map +0 -1
  156. package/lib/exposedInternalTypes.d.ts +0 -138
  157. package/lib/exposedInternalTypes.d.ts.map +0 -1
  158. package/lib/exposedInternalTypes.js +0 -16
  159. package/lib/exposedInternalTypes.js.map +0 -1
  160. package/lib/exposedUtilityTypes.d.ts +0 -108
  161. package/lib/exposedUtilityTypes.d.ts.map +0 -1
  162. package/lib/exposedUtilityTypes.js +0 -6
  163. package/lib/exposedUtilityTypes.js.map +0 -1
  164. package/lib/internalUtils.d.ts +0 -125
  165. package/lib/internalUtils.d.ts.map +0 -1
  166. package/lib/internalUtils.js +0 -90
  167. package/lib/internalUtils.js.map +0 -1
  168. package/lib/latestMapTypes.d.ts +0 -343
  169. package/lib/latestMapTypes.d.ts.map +0 -1
  170. package/lib/latestMapTypes.js +0 -6
  171. package/lib/latestMapTypes.js.map +0 -1
  172. package/lib/latestMapValueManager.d.ts +0 -52
  173. package/lib/latestMapValueManager.d.ts.map +0 -1
  174. package/lib/latestMapValueManager.js +0 -246
  175. package/lib/latestMapValueManager.js.map +0 -1
  176. package/lib/latestTypes.d.ts +0 -183
  177. package/lib/latestTypes.d.ts.map +0 -1
  178. package/lib/latestTypes.js +0 -6
  179. package/lib/latestTypes.js.map +0 -1
  180. package/lib/latestValueManager.d.ts +0 -10
  181. package/lib/latestValueManager.d.ts.map +0 -1
  182. package/lib/latestValueManager.js +0 -113
  183. package/lib/latestValueManager.js.map +0 -1
  184. package/lib/latestValueTypes.d.ts +0 -108
  185. package/lib/latestValueTypes.d.ts.map +0 -1
  186. package/lib/latestValueTypes.js +0 -6
  187. package/lib/latestValueTypes.js.map +0 -1
  188. package/lib/notificationsManager.d.ts +0 -27
  189. package/lib/notificationsManager.d.ts.map +0 -1
  190. package/lib/notificationsManager.js +0 -94
  191. package/lib/notificationsManager.js.map +0 -1
  192. package/lib/notificationsManagerTypes.d.ts +0 -144
  193. package/lib/notificationsManagerTypes.d.ts.map +0 -1
  194. package/lib/notificationsManagerTypes.js +0 -6
  195. package/lib/notificationsManagerTypes.js.map +0 -1
  196. package/lib/packageVersion.d.ts +0 -9
  197. package/lib/packageVersion.d.ts.map +0 -1
  198. package/lib/packageVersion.js +0 -9
  199. package/lib/packageVersion.js.map +0 -1
  200. package/lib/presence.d.ts +0 -229
  201. package/lib/presence.d.ts.map +0 -1
  202. package/lib/presence.js +0 -20
  203. package/lib/presence.js.map +0 -1
  204. package/lib/presenceDatastoreManager.d.ts +0 -149
  205. package/lib/presenceDatastoreManager.d.ts.map +0 -1
  206. package/lib/presenceDatastoreManager.js +0 -663
  207. package/lib/presenceDatastoreManager.js.map +0 -1
  208. package/lib/presenceManager.d.ts +0 -16
  209. package/lib/presenceManager.d.ts.map +0 -1
  210. package/lib/presenceManager.js +0 -136
  211. package/lib/presenceManager.js.map +0 -1
  212. package/lib/presenceStates.d.ts +0 -102
  213. package/lib/presenceStates.d.ts.map +0 -1
  214. package/lib/presenceStates.js +0 -225
  215. package/lib/presenceStates.js.map +0 -1
  216. package/lib/protocol.d.ts +0 -111
  217. package/lib/protocol.d.ts.map +0 -1
  218. package/lib/protocol.js +0 -17
  219. package/lib/protocol.js.map +0 -1
  220. package/lib/runtimeTypes.d.ts +0 -26
  221. package/lib/runtimeTypes.d.ts.map +0 -1
  222. package/lib/runtimeTypes.js +0 -6
  223. package/lib/runtimeTypes.js.map +0 -1
  224. package/lib/stateDatastore.d.ts +0 -56
  225. package/lib/stateDatastore.d.ts.map +0 -1
  226. package/lib/stateDatastore.js +0 -17
  227. package/lib/stateDatastore.js.map +0 -1
  228. package/lib/stateFactory.d.ts +0 -18
  229. package/lib/stateFactory.d.ts.map +0 -1
  230. package/lib/stateFactory.js +0 -20
  231. package/lib/stateFactory.js.map +0 -1
  232. package/lib/statesManagerTypes.d.ts +0 -27
  233. package/lib/statesManagerTypes.d.ts.map +0 -1
  234. package/lib/statesManagerTypes.js +0 -6
  235. package/lib/statesManagerTypes.js.map +0 -1
  236. package/lib/systemWorkspace.d.ts +0 -58
  237. package/lib/systemWorkspace.d.ts.map +0 -1
  238. package/lib/systemWorkspace.js +0 -261
  239. package/lib/systemWorkspace.js.map +0 -1
  240. package/lib/timerManager.d.ts +0 -37
  241. package/lib/timerManager.d.ts.map +0 -1
  242. package/lib/timerManager.js +0 -61
  243. package/lib/timerManager.js.map +0 -1
  244. package/lib/types.d.ts +0 -132
  245. package/lib/types.d.ts.map +0 -1
  246. package/lib/types.js +0 -6
  247. package/lib/types.js.map +0 -1
  248. package/lib/validatableTypes.d.ts +0 -69
  249. package/lib/validatableTypes.d.ts.map +0 -1
  250. package/lib/validatableTypes.js +0 -6
  251. package/lib/validatableTypes.js.map +0 -1
  252. package/lib/validatedGetter.d.ts +0 -18
  253. package/lib/validatedGetter.d.ts.map +0 -1
  254. package/lib/validatedGetter.js +0 -39
  255. package/lib/validatedGetter.js.map +0 -1
  256. package/lib/valueManager.d.ts +0 -15
  257. package/lib/valueManager.d.ts.map +0 -1
  258. package/lib/valueManager.js +0 -17
  259. package/lib/valueManager.js.map +0 -1
@@ -1,27 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import type { InternalTypes } from "./exposedInternalTypes.js";
6
- import type { Attendee } from "./presence.js";
7
- /**
8
- * A function to be called at the end of an update frame
9
- */
10
- export type PostUpdateAction = () => void;
11
- /**
12
- * Contract for State Managers as used by a States Workspace (`PresenceStatesImpl`)
13
- *
14
- * @remarks
15
- * See uses of `unbrandIVM`.
16
- */
17
- export interface ValueManager<TValue, TValueState extends InternalTypes.ValueDirectoryOrState<TValue> = InternalTypes.ValueDirectoryOrState<TValue>> {
18
- readonly value?: TValueState;
19
- /**
20
- * Process an update of `value` for remote attendee.
21
- * @param attendee - The attendee whose `value` is being updated
22
- * @param received - The revision number received
23
- * @param value - The new `value` state
24
- */
25
- update(attendee: Attendee, received: number, value: TValueState): PostUpdateAction[];
26
- }
27
- //# sourceMappingURL=statesManagerTypes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"statesManagerTypes.d.ts","sourceRoot":"","sources":["../src/statesManagerTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,WAAW,YAAY,CAC5B,MAAM,EACN,WAAW,SACV,aAAa,CAAC,qBAAqB,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,qBAAqB,CAAC,MAAM,CAAC;IAG1F,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAE7B;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,gBAAgB,EAAE,CAAC;CACrF"}
@@ -1,6 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- export {};
6
- //# sourceMappingURL=statesManagerTypes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"statesManagerTypes.js","sourceRoot":"","sources":["../src/statesManagerTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { Attendee } from \"./presence.js\";\n\n/**\n * A function to be called at the end of an update frame\n */\nexport type PostUpdateAction = () => void;\n\n/**\n * Contract for State Managers as used by a States Workspace (`PresenceStatesImpl`)\n *\n * @remarks\n * See uses of `unbrandIVM`.\n */\nexport interface ValueManager<\n\tTValue,\n\tTValueState extends\n\t\tInternalTypes.ValueDirectoryOrState<TValue> = InternalTypes.ValueDirectoryOrState<TValue>,\n> {\n\t// State objects should provide value - implement Required<ValueManager<...>>\n\treadonly value?: TValueState;\n\n\t/**\n\t * Process an update of `value` for remote attendee.\n\t * @param attendee - The attendee whose `value` is being updated\n\t * @param received - The revision number received\n\t * @param value - The new `value` state\n\t */\n\tupdate(attendee: Attendee, received: number, value: TValueState): PostUpdateAction[];\n}\n"]}
@@ -1,58 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import type { IAudience } from "@fluidframework/container-definitions";
6
- import type { IEmitter, Listenable } from "@fluidframework/core-interfaces/internal";
7
- import type { ClientConnectionId } from "./baseTypes.js";
8
- import type { InternalTypes } from "./exposedInternalTypes.js";
9
- import type { AttendeesEvents, AttendeeId, Presence } from "./presence.js";
10
- import type { PresenceStatesInternal } from "./presenceStates.js";
11
- import type { AnyWorkspace, StatesWorkspaceSchema } from "./types.js";
12
- /**
13
- * `ConnectionValueState` is known value state for `clientToSessionId` data.
14
- *
15
- * @remarks
16
- * It is {@link InternalTypes.ValueRequiredState} with a known value type.
17
- */
18
- interface ConnectionValueState extends InternalTypes.ValueStateMetadata {
19
- value: AttendeeId;
20
- }
21
- /**
22
- * The system workspace's datastore structure.
23
- */
24
- export interface SystemWorkspaceDatastore {
25
- clientToSessionId: {
26
- [ConnectionId: ClientConnectionId]: ConnectionValueState;
27
- };
28
- }
29
- /**
30
- * Internal workspace that manages metadata for session attendees.
31
- */
32
- export interface SystemWorkspace extends Exclude<Presence["attendees"], never> {
33
- /**
34
- * Must be called when the current client acquires a new connection.
35
- *
36
- * @param clientConnectionId - The new client connection ID.
37
- * @param audienceOutOfDate - When true, audience cannot be used as authoritative.
38
- */
39
- onConnectionAdded(clientConnectionId: ClientConnectionId, audienceOutOfDate: boolean): void;
40
- /**
41
- * Removes the client connection ID from the system workspace.
42
- *
43
- * @param clientConnectionId - The client connection ID to remove.
44
- */
45
- removeClientConnectionId(clientConnectionId: ClientConnectionId): void;
46
- }
47
- /**
48
- * Instantiates the system workspace.
49
- */
50
- export declare function createSystemWorkspace(attendeeId: AttendeeId, datastore: SystemWorkspaceDatastore, events: Listenable<AttendeesEvents> & IEmitter<AttendeesEvents>, audience: IAudience): {
51
- workspace: SystemWorkspace;
52
- statesEntry: {
53
- internal: PresenceStatesInternal;
54
- public: AnyWorkspace<StatesWorkspaceSchema>;
55
- };
56
- };
57
- export {};
58
- //# sourceMappingURL=systemWorkspace.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"systemWorkspace.d.ts","sour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EAAE,eAAe,CAAC;IAC3B,WAAW,EAAE;QACZ,QAAQ,EAAE,sBAAsB,CAAC;QACjC,MAAM,EAAE,YAAY,CAAC,qBAAqB,CAAC,CAAC;KAC5C,CAAC;CACF,CASA"}
@@ -1,261 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { assert } from "@fluidframework/core-utils/internal";
6
- import { revealOpaqueJson } from "./internalUtils.js";
7
- import { AttendeeStatus } from "./presence.js";
8
- import { TimerManager } from "./timerManager.js";
9
- class SessionClient {
10
- constructor(attendeeId,
11
- /**
12
- * Order is used to track the most recent client connection
13
- * during a session.
14
- */
15
- order = 0, connectionId = undefined) {
16
- this.attendeeId = attendeeId;
17
- this.order = order;
18
- this.connectionId = connectionId;
19
- this.connectionStatus = AttendeeStatus.Disconnected;
20
- }
21
- getConnectionId() {
22
- if (this.connectionId === undefined) {
23
- throw new Error("Client has never been connected");
24
- }
25
- return this.connectionId;
26
- }
27
- getConnectionStatus() {
28
- return this.connectionStatus;
29
- }
30
- setConnected() {
31
- this.connectionStatus = AttendeeStatus.Connected;
32
- }
33
- setDisconnected() {
34
- this.connectionStatus = AttendeeStatus.Disconnected;
35
- }
36
- }
37
- class SystemWorkspaceImpl {
38
- constructor(attendeeId, datastore, events, audience) {
39
- this.datastore = datastore;
40
- this.events = events;
41
- this.audience = audience;
42
- /**
43
- * `attendees` is this client's understanding of the attendees in the
44
- * session. The map covers entries for both session ids and connection
45
- * ids, which are never expected to collide, but if they did for same
46
- * client that would be fine.
47
- * An entry is for session ID if the value's `attendeeId` matches the key.
48
- */
49
- this.attendees = new Map();
50
- // When local client disconnects, we lose the connectivity status updates for remote attendees in the session.
51
- // Upon reconnect, we mark all other attendees connections as stale and update their status to disconnected after 30 seconds of inactivity.
52
- this.staleConnectionClients = new Set();
53
- this.staleConnectionTimer = new TimerManager();
54
- this.selfAttendee = new SessionClient(attendeeId);
55
- this.attendees.set(attendeeId, this.selfAttendee);
56
- }
57
- ensureContent(_content) {
58
- throw new Error("Method not implemented.");
59
- }
60
- processUpdate(_received, _timeModifier,
61
- /**
62
- * Remote datastore typed to match {@link PresenceStatesInternal.processUpdate}'s
63
- * `ValueUpdateRecord` type that uses {@link InternalTypes.ValueRequiredState}
64
- * and expects an Opaque JSON type. (We get away with a non-`unknown` value type
65
- * per TypeScript's method parameter bivariance.) Proper type would be
66
- * {@link ConnectionValueState} directly.
67
- * {@link ClientConnectionId} use for index is also a deviation, but conveniently
68
- * the accurate {@link AttendeeId} type is just a branded string, and
69
- * {@link ClientConnectionId} is just `string`.
70
- */
71
- remoteDatastore, senderConnectionId) {
72
- const audienceMembers = this.audience.getMembers();
73
- const postUpdateActions = [];
74
- for (const [clientConnectionId, value] of Object.entries(revealOpaqueJson(remoteDatastore.clientToSessionId))) {
75
- const attendeeId = value.value;
76
- const { attendee, isJoining } = this.ensureAttendee({
77
- attendeeId,
78
- clientConnectionId,
79
- order: value.rev,
80
- isSender: senderConnectionId === clientConnectionId,
81
- isInAudience: audienceMembers.has(clientConnectionId),
82
- });
83
- // If the attendee is joining the session, add them to the list of joining attendees to be announced later.
84
- if (isJoining) {
85
- postUpdateActions.push(() => this.events.emit("attendeeConnected", attendee));
86
- }
87
- const knownSessionId = this.datastore.clientToSessionId[clientConnectionId];
88
- if (knownSessionId === undefined) {
89
- this.datastore.clientToSessionId[clientConnectionId] = value;
90
- }
91
- else {
92
- assert(knownSessionId.value === value.value, 0xa5a /* Mismatched SessionId */);
93
- }
94
- }
95
- return postUpdateActions;
96
- }
97
- onConnectionAdded(clientConnectionId, audienceOutOfDate) {
98
- assert(this.selfAttendee.getConnectionStatus() === AttendeeStatus.Disconnected, 0xaad /* Local client should be 'Disconnected' before adding new connection. */);
99
- const selfInAudience = this.audience.getMember(clientConnectionId) !== undefined;
100
- assert(selfInAudience || audienceOutOfDate, 0xcc0 /* Local client must be in audience for presence to handle added connection. */);
101
- if (!(clientConnectionId in this.datastore.clientToSessionId)) {
102
- this.datastore.clientToSessionId[clientConnectionId] = {
103
- rev: this.selfAttendee.order++,
104
- timestamp: Date.now(),
105
- value: this.selfAttendee.attendeeId,
106
- };
107
- }
108
- // Update the self attendee connection information, but not connection
109
- // status yet. Connection status is updated once self is in audience -
110
- // see later. It is only once our connection is known to audience that
111
- // audience can be used to track other attendees' connection statuses
112
- // and we seek to present a consistent view locally.
113
- this.selfAttendee.connectionId = clientConnectionId;
114
- this.attendees.set(clientConnectionId, this.selfAttendee);
115
- if (selfInAudience) {
116
- // Mark 'Connected' remote attendees connections as stale
117
- // Performance note: This will visit attendees multiple times as the
118
- // attendee map has attendeeIds and connectionIds entries that point to
119
- // the same attendee. But the getConnectionStatus check is cheap and
120
- // staleConnectionClients.add will handle duplicates.
121
- this.staleConnectionClients.clear();
122
- for (const staleConnectionClient of this.attendees.values()) {
123
- if (staleConnectionClient.getConnectionStatus() === AttendeeStatus.Connected) {
124
- this.staleConnectionClients.add(staleConnectionClient);
125
- }
126
- }
127
- this.staleConnectionTimer.setTimeout(this.resolveStaleConnections.bind(this), 30_000);
128
- this.selfAttendee.setConnected();
129
- this.events.emit("attendeeConnected", this.selfAttendee);
130
- }
131
- }
132
- resolveStaleConnections() {
133
- const consideredDisconnected = [];
134
- for (const client of this.staleConnectionClients) {
135
- // Confirm that audience no longer has connection. It is possible
136
- // but unlikely that no one mentioned the attendee in this period
137
- // and that they were never disconnected.
138
- if (this.audience.getMember(client.getConnectionId()) === undefined) {
139
- consideredDisconnected.push(client);
140
- client.setDisconnected();
141
- }
142
- }
143
- for (const client of consideredDisconnected) {
144
- this.events.emit("attendeeDisconnected", client);
145
- }
146
- this.staleConnectionClients.clear();
147
- }
148
- removeClientConnectionId(clientConnectionId) {
149
- const attendee = this.attendees.get(clientConnectionId);
150
- if (!attendee) {
151
- return;
152
- }
153
- // If the local connection is being removed, clear the stale connection timer
154
- if (attendee === this.selfAttendee) {
155
- this.staleConnectionTimer.clearTimeout();
156
- }
157
- else {
158
- // When self is not connected, audience may go through a refresh that
159
- // removes members and adds them back. Defer any removals until self
160
- // is connected implying audience is stable.
161
- if (this.selfAttendee.getConnectionStatus() !== AttendeeStatus.Connected) {
162
- return;
163
- }
164
- }
165
- // If the last known connectionID is different from the connection ID being removed, the attendee has reconnected,
166
- // therefore we should not change the attendee connection status or emit a disconnect event.
167
- const attendeeReconnected = attendee.getConnectionId() !== clientConnectionId;
168
- const connected = attendee.getConnectionStatus() === AttendeeStatus.Connected;
169
- if (!attendeeReconnected && connected) {
170
- attendee.setDisconnected();
171
- this.events.emit("attendeeDisconnected", attendee);
172
- this.staleConnectionClients.delete(attendee);
173
- }
174
- }
175
- getAttendees() {
176
- return new Set(this.attendees.values());
177
- }
178
- getAttendee(clientId) {
179
- const attendee = this.attendees.get(clientId);
180
- if (attendee) {
181
- return attendee;
182
- }
183
- // TODO: Restore option to add attendee on demand to handle internal
184
- // lookup cases that must come from internal data.
185
- // There aren't any resiliency mechanisms in place to handle a missed
186
- // ClientJoin right now.
187
- throw new Error("Attendee not found");
188
- }
189
- getMyself() {
190
- return this.selfAttendee;
191
- }
192
- /**
193
- * Make sure the given client session and connection ID pair are represented
194
- * in the attendee map. If not present, SessionClient is created and added
195
- * to map. If present, make sure the current connection ID is updated.
196
- */
197
- ensureAttendee({ attendeeId, clientConnectionId, order, isSender, isInAudience, }) {
198
- let attendee = this.attendees.get(attendeeId);
199
- let isConnected = false;
200
- let isJoining = false;
201
- if (attendee === undefined) {
202
- // New attendee. Create SessionClient and add session ID based
203
- // entry to map.
204
- attendee = new SessionClient(attendeeId, order, clientConnectionId);
205
- this.attendees.set(attendeeId, attendee);
206
- // If the attendee update is from the sending remote client itself
207
- // OR if the attendee is present in audience,
208
- // then the attendee is considered connected. (Otherwise, leave
209
- // state as disconnected - default.)
210
- if (isSender || isInAudience) {
211
- isConnected = true;
212
- attendee.setConnected();
213
- isJoining = true;
214
- }
215
- }
216
- else {
217
- // Known attendee is considered connected if
218
- isConnected =
219
- // this information is at least up to date with current knowledge
220
- order >= attendee.order &&
221
- // AND in the audience OR
222
- (isInAudience ||
223
- // not in audience, but client is the sender and has newer
224
- // info. (Assume that audience is out of date and attendee
225
- // is joining.)
226
- (isSender && order > attendee.order));
227
- if (order > attendee.order) {
228
- // The given association is newer than the one we have.
229
- // Update the order and current connection ID.
230
- attendee.order = order;
231
- attendee.connectionId = clientConnectionId;
232
- }
233
- // Known attendee is joining the session if they are currently disconnected.
234
- if (isConnected && attendee.getConnectionStatus() === AttendeeStatus.Disconnected) {
235
- attendee.setConnected();
236
- isJoining = true;
237
- }
238
- }
239
- if (isConnected) {
240
- // If the attendee is connected, remove them from the stale connection set
241
- this.staleConnectionClients.delete(attendee);
242
- }
243
- // Always update entry for the connection ID. (Okay if already set.)
244
- this.attendees.set(clientConnectionId, attendee);
245
- return { attendee, isJoining };
246
- }
247
- }
248
- /**
249
- * Instantiates the system workspace.
250
- */
251
- export function createSystemWorkspace(attendeeId, datastore, events, audience) {
252
- const workspace = new SystemWorkspaceImpl(attendeeId, datastore, events, audience);
253
- return {
254
- workspace,
255
- statesEntry: {
256
- internal: workspace,
257
- public: undefined,
258
- },
259
- };
260
- }
261
- //# sourceMappingURL=systemWorkspace.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"systemWorkspace.js","sourceRoot":"","sources":["../src/systemWorkspace.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAI7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAsBjD,MAAM,aAAa;IAGlB,YACiB,UAAsB;IACtC;;;OAGG;IACI,QAAgB,CAAC,EACjB,eAA+C,SAAS;QAN/C,eAAU,GAAV,UAAU,CAAY;QAK/B,UAAK,GAAL,KAAK,CAAY;QACjB,i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AEjD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IAChC,CAAC;CACD;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACpC,UAAsB,EACtB,SAAmC,EACnC,MAA+D,EAC/D,QAAmB;IAQnB,MAAM,SAAS,GAAG,IAAI,mBAAmB,CAAC,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IACnF,OAAO;QACN,SAAS;QACT,WAAW,EAAE;YACZ,QAAQ,EAAE,SAAS;YACnB,MAAM,EAAE,SAA2D;SACnE;KACD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IAudience } from \"@fluidframework/container-definitions\";\nimport type { IEmitter, Listenable } from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { ClientConnectionId } from \"./baseTypes.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport { revealOpaqueJson } from \"./internalUtils.js\";\nimport type { Attendee, AttendeesEvents, AttendeeId, Presence } from \"./presence.js\";\nimport { AttendeeStatus } from \"./presence.js\";\nimport type { PresenceStatesInternal } from \"./presenceStates.js\";\nimport type { PostUpdateAction } from \"./statesManagerTypes.js\";\nimport { TimerManager } from \"./timerManager.js\";\nimport type { AnyWorkspace, StatesWorkspaceSchema } from \"./types.js\";\n\n/**\n * `ConnectionValueState` is known value state for `clientToSessionId` data.\n *\n * @remarks\n * It is {@link InternalTypes.ValueRequiredState} with a known value type.\n */\ninterface ConnectionValueState extends InternalTypes.ValueStateMetadata {\n\tvalue: AttendeeId;\n}\n\n/**\n * The system workspace's datastore structure.\n */\nexport interface SystemWorkspaceDatastore {\n\tclientToSessionId: {\n\t\t[ConnectionId: ClientConnectionId]: ConnectionValueState;\n\t};\n}\n\nclass SessionClient implements Attendee {\n\tprivate connectionStatus: AttendeeStatus = AttendeeStatus.Disconnected;\n\n\tpublic constructor(\n\t\tpublic readonly attendeeId: AttendeeId,\n\t\t/**\n\t\t * Order is used to track the most recent client connection\n\t\t * during a session.\n\t\t */\n\t\tpublic order: number = 0,\n\t\tpublic connectionId: ClientConnectionId | undefined = undefined,\n\t) {}\n\n\tpublic getConnectionId(): ClientConnectionId {\n\t\tif (this.connectionId === undefined) {\n\t\t\tthrow new Error(\"Client has never been connected\");\n\t\t}\n\t\treturn this.connectionId;\n\t}\n\n\tpublic getConnectionStatus(): AttendeeStatus {\n\t\treturn this.connectionStatus;\n\t}\n\n\tpublic setConnected(): void {\n\t\tthis.connectionStatus = AttendeeStatus.Connected;\n\t}\n\n\tpublic setDisconnected(): void {\n\t\tthis.connectionStatus = AttendeeStatus.Disconnected;\n\t}\n}\n\n/**\n * Internal workspace that manages metadata for session attendees.\n */\nexport interface SystemWorkspace\n\t// Portion of Presence that is handled by SystemWorkspace along with\n\t// responsibility for emitting \"attendeeConnected\" events.\n\textends Exclude<Presence[\"attendees\"], never> {\n\t/**\n\t * Must be called when the current client acquires a new connection.\n\t *\n\t * @param clientConnectionId - The new client connection ID.\n\t * @param audienceOutOfDate - When true, audience cannot be used as authoritative.\n\t */\n\tonConnectionAdded(clientConnectionId: ClientConnectionId, audienceOutOfDate: boolean): void;\n\n\t/**\n\t * Removes the client connection ID from the system workspace.\n\t *\n\t * @param clientConnectionId - The client connection ID to remove.\n\t */\n\tremoveClientConnectionId(clientConnectionId: ClientConnectionId): void;\n}\n\nclass SystemWorkspaceImpl implements PresenceStatesInternal, SystemWorkspace {\n\tprivate readonly selfAttendee: SessionClient;\n\t/**\n\t * `attendees` is this client's understanding of the attendees in the\n\t * session. The map covers entries for both session ids and connection\n\t * ids, which are never expected to collide, but if they did for same\n\t * client that would be fine.\n\t * An entry is for session ID if the value's `attendeeId` matches the key.\n\t */\n\tprivate readonly attendees = new Map<ClientConnectionId | AttendeeId, SessionClient>();\n\n\t// When local client disconnects, we lose the connectivity status updates for remote attendees in the session.\n\t// Upon reconnect, we mark all other attendees connections as stale and update their status to disconnected after 30 seconds of inactivity.\n\tprivate readonly staleConnectionClients = new Set<SessionClient>();\n\n\tprivate readonly staleConnectionTimer = new TimerManager();\n\n\tpublic constructor(\n\t\tattendeeId: AttendeeId,\n\t\tprivate readonly datastore: SystemWorkspaceDatastore,\n\t\tpublic readonly events: Listenable<AttendeesEvents> & IEmitter<AttendeesEvents>,\n\t\tprivate readonly audience: IAudience,\n\t) {\n\t\tthis.selfAttendee = new SessionClient(attendeeId);\n\t\tthis.attendees.set(attendeeId, this.selfAttendee);\n\t}\n\n\tpublic ensureContent<TSchemaAdditional extends StatesWorkspaceSchema>(\n\t\t_content: TSchemaAdditional,\n\t): never {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\tpublic processUpdate(\n\t\t_received: number,\n\t\t_timeModifier: number,\n\t\t/**\n\t\t * Remote datastore typed to match {@link PresenceStatesInternal.processUpdate}'s\n\t\t * `ValueUpdateRecord` type that uses {@link InternalTypes.ValueRequiredState}\n\t\t * and expects an Opaque JSON type. (We get away with a non-`unknown` value type\n\t\t * per TypeScript's method parameter bivariance.) Proper type would be\n\t\t * {@link ConnectionValueState} directly.\n\t\t * {@link ClientConnectionId} use for index is also a deviation, but conveniently\n\t\t * the accurate {@link AttendeeId} type is just a branded string, and\n\t\t * {@link ClientConnectionId} is just `string`.\n\t\t */\n\t\tremoteDatastore: {\n\t\t\tclientToSessionId: {\n\t\t\t\t[ConnectionId: ClientConnectionId]: InternalTypes.ValueRequiredState<\n\t\t\t\t\tConnectionValueState[\"value\"]\n\t\t\t\t>;\n\t\t\t};\n\t\t},\n\t\tsenderConnectionId: ClientConnectionId,\n\t): PostUpdateAction[] {\n\t\tconst audienceMembers = this.audience.getMembers();\n\t\tconst postUpdateActions: PostUpdateAction[] = [];\n\t\tfor (const [clientConnectionId, value] of Object.entries(\n\t\t\trevealOpaqueJson(remoteDatastore.clientToSessionId),\n\t\t)) {\n\t\t\tconst attendeeId = value.value;\n\t\t\tconst { attendee, isJoining } = this.ensureAttendee({\n\t\t\t\tattendeeId,\n\t\t\t\tclientConnectionId,\n\t\t\t\torder: value.rev,\n\t\t\t\tisSender: senderConnectionId === clientConnectionId,\n\t\t\t\tisInAudience: audienceMembers.has(clientConnectionId),\n\t\t\t});\n\t\t\t// If the attendee is joining the session, add them to the list of joining attendees to be announced later.\n\t\t\tif (isJoining) {\n\t\t\t\tpostUpdateActions.push(() => this.events.emit(\"attendeeConnected\", attendee));\n\t\t\t}\n\n\t\t\tconst knownSessionId = this.datastore.clientToSessionId[clientConnectionId];\n\t\t\tif (knownSessionId === undefined) {\n\t\t\t\tthis.datastore.clientToSessionId[clientConnectionId] = value;\n\t\t\t} else {\n\t\t\t\tassert(knownSessionId.value === value.value, 0xa5a /* Mismatched SessionId */);\n\t\t\t}\n\t\t}\n\n\t\treturn postUpdateActions;\n\t}\n\n\tpublic onConnectionAdded(\n\t\tclientConnectionId: ClientConnectionId,\n\t\taudienceOutOfDate: boolean,\n\t): void {\n\t\tassert(\n\t\t\tthis.selfAttendee.getConnectionStatus() === AttendeeStatus.Disconnected,\n\t\t\t0xaad /* Local client should be 'Disconnected' before adding new connection. */,\n\t\t);\n\n\t\tconst selfInAudience = this.audience.getMember(clientConnectionId) !== undefined;\n\t\tassert(\n\t\t\tselfInAudience || audienceOutOfDate,\n\t\t\t0xcc0 /* Local client must be in audience for presence to handle added connection. */,\n\t\t);\n\n\t\tif (!(clientConnectionId in this.datastore.clientToSessionId)) {\n\t\t\tthis.datastore.clientToSessionId[clientConnectionId] = {\n\t\t\t\trev: this.selfAttendee.order++,\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t\tvalue: this.selfAttendee.attendeeId,\n\t\t\t};\n\t\t}\n\n\t\t// Update the self attendee connection information, but not connection\n\t\t// status yet. Connection status is updated once self is in audience -\n\t\t// see later. It is only once our connection is known to audience that\n\t\t// audience can be used to track other attendees' connection statuses\n\t\t// and we seek to present a consistent view locally.\n\t\tthis.selfAttendee.connectionId = clientConnectionId;\n\t\tthis.attendees.set(clientConnectionId, this.selfAttendee);\n\n\t\tif (selfInAudience) {\n\t\t\t// Mark 'Connected' remote attendees connections as stale\n\t\t\t// Performance note: This will visit attendees multiple times as the\n\t\t\t// attendee map has attendeeIds and connectionIds entries that point to\n\t\t\t// the same attendee. But the getConnectionStatus check is cheap and\n\t\t\t// staleConnectionClients.add will handle duplicates.\n\t\t\tthis.staleConnectionClients.clear();\n\t\t\tfor (const staleConnectionClient of this.attendees.values()) {\n\t\t\t\tif (staleConnectionClient.getConnectionStatus() === AttendeeStatus.Connected) {\n\t\t\t\t\tthis.staleConnectionClients.add(staleConnectionClient);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.staleConnectionTimer.setTimeout(this.resolveStaleConnections.bind(this), 30_000);\n\n\t\t\tthis.selfAttendee.setConnected();\n\t\t\tthis.events.emit(\"attendeeConnected\", this.selfAttendee);\n\t\t}\n\t}\n\n\tprivate resolveStaleConnections(): void {\n\t\tconst consideredDisconnected = [];\n\t\tfor (const client of this.staleConnectionClients) {\n\t\t\t// Confirm that audience no longer has connection. It is possible\n\t\t\t// but unlikely that no one mentioned the attendee in this period\n\t\t\t// and that they were never disconnected.\n\t\t\tif (this.audience.getMember(client.getConnectionId()) === undefined) {\n\t\t\t\tconsideredDisconnected.push(client);\n\t\t\t\tclient.setDisconnected();\n\t\t\t}\n\t\t}\n\t\tfor (const client of consideredDisconnected) {\n\t\t\tthis.events.emit(\"attendeeDisconnected\", client);\n\t\t}\n\t\tthis.staleConnectionClients.clear();\n\t}\n\n\tpublic removeClientConnectionId(clientConnectionId: ClientConnectionId): void {\n\t\tconst attendee = this.attendees.get(clientConnectionId);\n\t\tif (!attendee) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If the local connection is being removed, clear the stale connection timer\n\t\tif (attendee === this.selfAttendee) {\n\t\t\tthis.staleConnectionTimer.clearTimeout();\n\t\t} else {\n\t\t\t// When self is not connected, audience may go through a refresh that\n\t\t\t// removes members and adds them back. Defer any removals until self\n\t\t\t// is connected implying audience is stable.\n\t\t\tif (this.selfAttendee.getConnectionStatus() !== AttendeeStatus.Connected) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// If the last known connectionID is different from the connection ID being removed, the attendee has reconnected,\n\t\t// therefore we should not change the attendee connection status or emit a disconnect event.\n\t\tconst attendeeReconnected = attendee.getConnectionId() !== clientConnectionId;\n\t\tconst connected = attendee.getConnectionStatus() === AttendeeStatus.Connected;\n\t\tif (!attendeeReconnected && connected) {\n\t\t\tattendee.setDisconnected();\n\t\t\tthis.events.emit(\"attendeeDisconnected\", attendee);\n\t\t\tthis.staleConnectionClients.delete(attendee);\n\t\t}\n\t}\n\n\tpublic getAttendees(): ReadonlySet<Attendee> {\n\t\treturn new Set(this.attendees.values());\n\t}\n\n\tpublic getAttendee(clientId: ClientConnectionId | AttendeeId): Attendee {\n\t\tconst attendee = this.attendees.get(clientId);\n\t\tif (attendee) {\n\t\t\treturn attendee;\n\t\t}\n\n\t\t// TODO: Restore option to add attendee on demand to handle internal\n\t\t// lookup cases that must come from internal data.\n\t\t// There aren't any resiliency mechanisms in place to handle a missed\n\t\t// ClientJoin right now.\n\t\tthrow new Error(\"Attendee not found\");\n\t}\n\n\tpublic getMyself(): Attendee {\n\t\treturn this.selfAttendee;\n\t}\n\n\t/**\n\t * Make sure the given client session and connection ID pair are represented\n\t * in the attendee map. If not present, SessionClient is created and added\n\t * to map. If present, make sure the current connection ID is updated.\n\t */\n\tprivate ensureAttendee({\n\t\tattendeeId,\n\t\tclientConnectionId,\n\t\torder,\n\t\tisSender,\n\t\tisInAudience,\n\t}: {\n\t\tattendeeId: AttendeeId;\n\t\tclientConnectionId: ClientConnectionId;\n\t\torder: number;\n\t\tisSender: boolean;\n\t\tisInAudience: boolean;\n\t}): { attendee: SessionClient; isJoining: boolean } {\n\t\tlet attendee = this.attendees.get(attendeeId);\n\t\tlet isConnected = false;\n\t\tlet isJoining = false;\n\n\t\tif (attendee === undefined) {\n\t\t\t// New attendee. Create SessionClient and add session ID based\n\t\t\t// entry to map.\n\t\t\tattendee = new SessionClient(attendeeId, order, clientConnectionId);\n\t\t\tthis.attendees.set(attendeeId, attendee);\n\t\t\t// If the attendee update is from the sending remote client itself\n\t\t\t// OR if the attendee is present in audience,\n\t\t\t// then the attendee is considered connected. (Otherwise, leave\n\t\t\t// state as disconnected - default.)\n\t\t\tif (isSender || isInAudience) {\n\t\t\t\tisConnected = true;\n\t\t\t\tattendee.setConnected();\n\t\t\t\tisJoining = true;\n\t\t\t}\n\t\t} else {\n\t\t\t// Known attendee is considered connected if\n\t\t\tisConnected =\n\t\t\t\t// this information is at least up to date with current knowledge\n\t\t\t\torder >= attendee.order &&\n\t\t\t\t// AND in the audience OR\n\t\t\t\t(isInAudience ||\n\t\t\t\t\t// not in audience, but client is the sender and has newer\n\t\t\t\t\t// info. (Assume that audience is out of date and attendee\n\t\t\t\t\t// is joining.)\n\t\t\t\t\t(isSender && order > attendee.order));\n\n\t\t\tif (order > attendee.order) {\n\t\t\t\t// The given association is newer than the one we have.\n\t\t\t\t// Update the order and current connection ID.\n\t\t\t\tattendee.order = order;\n\t\t\t\tattendee.connectionId = clientConnectionId;\n\t\t\t}\n\n\t\t\t// Known attendee is joining the session if they are currently disconnected.\n\t\t\tif (isConnected && attendee.getConnectionStatus() === AttendeeStatus.Disconnected) {\n\t\t\t\tattendee.setConnected();\n\t\t\t\tisJoining = true;\n\t\t\t}\n\t\t}\n\n\t\tif (isConnected) {\n\t\t\t// If the attendee is connected, remove them from the stale connection set\n\t\t\tthis.staleConnectionClients.delete(attendee);\n\t\t}\n\n\t\t// Always update entry for the connection ID. (Okay if already set.)\n\t\tthis.attendees.set(clientConnectionId, attendee);\n\n\t\treturn { attendee, isJoining };\n\t}\n}\n\n/**\n * Instantiates the system workspace.\n */\nexport function createSystemWorkspace(\n\tattendeeId: AttendeeId,\n\tdatastore: SystemWorkspaceDatastore,\n\tevents: Listenable<AttendeesEvents> & IEmitter<AttendeesEvents>,\n\taudience: IAudience,\n): {\n\tworkspace: SystemWorkspace;\n\tstatesEntry: {\n\t\tinternal: PresenceStatesInternal;\n\t\tpublic: AnyWorkspace<StatesWorkspaceSchema>;\n\t};\n} {\n\tconst workspace = new SystemWorkspaceImpl(attendeeId, datastore, events, audience);\n\treturn {\n\t\tworkspace,\n\t\tstatesEntry: {\n\t\t\tinternal: workspace,\n\t\t\tpublic: undefined as unknown as AnyWorkspace<StatesWorkspaceSchema>,\n\t\t},\n\t};\n}\n"]}
@@ -1,37 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- /**
6
- * Wrapper around setTimeout to track whether the timeout has expired or not.
7
- */
8
- export declare class TimerManager {
9
- private _timeoutId;
10
- private _startTime;
11
- get startTime(): number;
12
- private _delay;
13
- get delay(): number;
14
- private _expired;
15
- /**
16
- * Whether the timer has expired or not.
17
- *
18
- * @returns True if the timer has expired; false otherwise.
19
- */
20
- hasExpired(): boolean;
21
- /**
22
- * Schedules a callback to be triggered after a delay.
23
- *
24
- * @param callback - A callback to execute after a delay.
25
- * @param delay - The time to wait before executing the callback, in milliseconds.
26
- */
27
- setTimeout(callback: () => void, delay: number): void;
28
- /**
29
- * Clear any pending timer. Also marks the timer as expired.
30
- */
31
- clearTimeout(): void;
32
- /**
33
- * The time when this timer will expire/trigger. If the timer has expired, returns 0.
34
- */
35
- get expireTime(): number;
36
- }
37
- //# sourceMappingURL=timerManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"timerManager.d.ts","sourceRoot":"","sources":["../src/timerManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,qBAAa,YAAY;IACxB,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,UAAU,CAAK;IAEvB,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED,OAAO,CAAC,MAAM,CAAa;IAE3B,IAAW,KAAK,IAAI,MAAM,CAEzB;IAED,OAAO,CAAC,QAAQ,CAAiB;IAEjC;;;;OAIG;IACI,UAAU,IAAI,OAAO;IAI5B;;;;;OAKG;IACI,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAW5D;;OAEG;IACI,YAAY,IAAI,IAAI;IAQ3B;;OAEG;IACH,IAAW,UAAU,IAAI,MAAM,CAE9B;CACD"}
@@ -1,61 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- /**
6
- * Wrapper around setTimeout to track whether the timeout has expired or not.
7
- */
8
- export class TimerManager {
9
- constructor() {
10
- this._startTime = 0;
11
- this._delay = 0;
12
- this._expired = true;
13
- }
14
- get startTime() {
15
- return this._startTime;
16
- }
17
- get delay() {
18
- return this._delay;
19
- }
20
- /**
21
- * Whether the timer has expired or not.
22
- *
23
- * @returns True if the timer has expired; false otherwise.
24
- */
25
- hasExpired() {
26
- return this._expired;
27
- }
28
- /**
29
- * Schedules a callback to be triggered after a delay.
30
- *
31
- * @param callback - A callback to execute after a delay.
32
- * @param delay - The time to wait before executing the callback, in milliseconds.
33
- */
34
- setTimeout(callback, delay) {
35
- this.clearTimeout(); // Clear any existing timeout
36
- this._startTime = Date.now();
37
- this._delay = delay;
38
- this._expired = false;
39
- this._timeoutId = setTimeout(() => {
40
- this._expired = true;
41
- callback();
42
- }, delay);
43
- }
44
- /**
45
- * Clear any pending timer. Also marks the timer as expired.
46
- */
47
- clearTimeout() {
48
- if (this._timeoutId !== undefined) {
49
- clearTimeout(this._timeoutId);
50
- this._timeoutId = undefined;
51
- this._expired = true;
52
- }
53
- }
54
- /**
55
- * The time when this timer will expire/trigger. If the timer has expired, returns 0.
56
- */
57
- get expireTime() {
58
- return this.hasExpired() ? 0 : this.startTime + this.delay;
59
- }
60
- }
61
- //# sourceMappingURL=timerManager.js.map
@@ -1 +0,0 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CAAC,KAAK,CAAC;IAC5D,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Wrapper around setTimeout to track whether the timeout has expired or not.\n */\nexport class TimerManager {\n\tprivate _timeoutId: number | undefined;\n\tprivate _startTime = 0;\n\n\tpublic get startTime(): number {\n\t\treturn this._startTime;\n\t}\n\n\tprivate _delay: number = 0;\n\n\tpublic get delay(): number {\n\t\treturn this._delay;\n\t}\n\n\tprivate _expired: boolean = true;\n\n\t/**\n\t * Whether the timer has expired or not.\n\t *\n\t * @returns True if the timer has expired; false otherwise.\n\t */\n\tpublic hasExpired(): boolean {\n\t\treturn this._expired;\n\t}\n\n\t/**\n\t * Schedules a callback to be triggered after a delay.\n\t *\n\t * @param callback - A callback to execute after a delay.\n\t * @param delay - The time to wait before executing the callback, in milliseconds.\n\t */\n\tpublic setTimeout(callback: () => void, delay: number): void {\n\t\tthis.clearTimeout(); // Clear any existing timeout\n\t\tthis._startTime = Date.now();\n\t\tthis._delay = delay;\n\t\tthis._expired = false;\n\t\tthis._timeoutId = setTimeout(() => {\n\t\t\tthis._expired = true;\n\t\t\tcallback();\n\t\t}, delay);\n\t}\n\n\t/**\n\t * Clear any pending timer. Also marks the timer as expired.\n\t */\n\tpublic clearTimeout(): void {\n\t\tif (this._timeoutId !== undefined) {\n\t\t\tclearTimeout(this._timeoutId);\n\t\t\tthis._timeoutId = undefined;\n\t\t\tthis._expired = true;\n\t\t}\n\t}\n\n\t/**\n\t * The time when this timer will expire/trigger. If the timer has expired, returns 0.\n\t */\n\tpublic get expireTime(): number {\n\t\treturn this.hasExpired() ? 0 : this.startTime + this.delay;\n\t}\n}\n"]}