@fluidframework/presence 2.32.0 → 2.33.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.
- package/README.md +24 -24
- package/dist/alpha.d.ts +29 -25
- package/dist/baseTypes.d.ts +3 -3
- package/dist/baseTypes.js.map +1 -1
- package/dist/broadcastControls.d.ts +1 -1
- package/dist/broadcastControls.js.map +1 -1
- package/dist/datastorePresenceManagerFactory.d.ts +5 -5
- package/dist/datastorePresenceManagerFactory.d.ts.map +1 -1
- package/dist/datastorePresenceManagerFactory.js +6 -6
- package/dist/datastorePresenceManagerFactory.js.map +1 -1
- package/dist/experimentalAccess.d.ts +4 -4
- package/dist/experimentalAccess.d.ts.map +1 -1
- package/dist/experimentalAccess.js +6 -6
- package/dist/experimentalAccess.js.map +1 -1
- package/dist/exposedInternalTypes.d.ts +1 -1
- package/dist/exposedInternalTypes.js.map +1 -1
- package/dist/exposedUtilityTypes.d.ts +0 -8
- package/dist/exposedUtilityTypes.d.ts.map +1 -1
- package/dist/exposedUtilityTypes.js.map +1 -1
- package/dist/index.d.ts +8 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -8
- package/dist/index.js.map +1 -1
- package/dist/internalTypes.d.ts +3 -3
- package/dist/internalTypes.d.ts.map +1 -1
- package/dist/internalTypes.js.map +1 -1
- package/dist/internalUtils.d.ts +5 -0
- package/dist/internalUtils.d.ts.map +1 -1
- package/dist/internalUtils.js +8 -1
- package/dist/internalUtils.js.map +1 -1
- package/dist/latestMapValueManager.d.ts +57 -39
- package/dist/latestMapValueManager.d.ts.map +1 -1
- package/dist/latestMapValueManager.js +48 -39
- package/dist/latestMapValueManager.js.map +1 -1
- package/dist/latestValueManager.d.ts +38 -20
- package/dist/latestValueManager.d.ts.map +1 -1
- package/dist/latestValueManager.js +32 -28
- package/dist/latestValueManager.js.map +1 -1
- package/dist/latestValueTypes.d.ts +9 -10
- package/dist/latestValueTypes.d.ts.map +1 -1
- package/dist/latestValueTypes.js.map +1 -1
- package/dist/notificationsManager.d.ts +15 -10
- package/dist/notificationsManager.d.ts.map +1 -1
- package/dist/notificationsManager.js +8 -5
- package/dist/notificationsManager.js.map +1 -1
- package/dist/presence.d.ts +82 -66
- package/dist/presence.d.ts.map +1 -1
- package/dist/presence.js +5 -5
- package/dist/presence.js.map +1 -1
- package/dist/presenceDatastoreManager.d.ts +12 -10
- package/dist/presenceDatastoreManager.d.ts.map +1 -1
- package/dist/presenceDatastoreManager.js +10 -8
- package/dist/presenceDatastoreManager.js.map +1 -1
- package/dist/presenceManager.d.ts +2 -2
- package/dist/presenceManager.d.ts.map +1 -1
- package/dist/presenceManager.js +14 -22
- package/dist/presenceManager.js.map +1 -1
- package/dist/presenceStates.d.ts +14 -13
- package/dist/presenceStates.d.ts.map +1 -1
- package/dist/presenceStates.js +22 -15
- package/dist/presenceStates.js.map +1 -1
- package/dist/stateDatastore.d.ts +5 -4
- package/dist/stateDatastore.d.ts.map +1 -1
- package/dist/stateDatastore.js.map +1 -1
- package/dist/stateFactory.d.ts +22 -0
- package/dist/stateFactory.d.ts.map +1 -0
- package/dist/stateFactory.js +25 -0
- package/dist/stateFactory.js.map +1 -0
- package/dist/systemWorkspace.d.ts +7 -7
- package/dist/systemWorkspace.d.ts.map +1 -1
- package/dist/systemWorkspace.js +23 -23
- package/dist/systemWorkspace.js.map +1 -1
- package/dist/types.d.ts +50 -33
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -1
- package/dist/types.js.map +1 -1
- package/lib/alpha.d.ts +29 -25
- package/lib/baseTypes.d.ts +3 -3
- package/lib/baseTypes.js.map +1 -1
- package/lib/broadcastControls.d.ts +1 -1
- package/lib/broadcastControls.js.map +1 -1
- package/lib/datastorePresenceManagerFactory.d.ts +5 -5
- package/lib/datastorePresenceManagerFactory.d.ts.map +1 -1
- package/lib/datastorePresenceManagerFactory.js +4 -4
- package/lib/datastorePresenceManagerFactory.js.map +1 -1
- package/lib/experimentalAccess.d.ts +4 -4
- package/lib/experimentalAccess.d.ts.map +1 -1
- package/lib/experimentalAccess.js +4 -4
- package/lib/experimentalAccess.js.map +1 -1
- package/lib/exposedInternalTypes.d.ts +1 -1
- package/lib/exposedInternalTypes.js.map +1 -1
- package/lib/exposedUtilityTypes.d.ts +0 -8
- package/lib/exposedUtilityTypes.d.ts.map +1 -1
- package/lib/exposedUtilityTypes.js.map +1 -1
- package/lib/index.d.ts +8 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -5
- package/lib/index.js.map +1 -1
- package/lib/internalTypes.d.ts +3 -3
- package/lib/internalTypes.d.ts.map +1 -1
- package/lib/internalTypes.js.map +1 -1
- package/lib/internalUtils.d.ts +5 -0
- package/lib/internalUtils.d.ts.map +1 -1
- package/lib/internalUtils.js +6 -0
- package/lib/internalUtils.js.map +1 -1
- package/lib/latestMapValueManager.d.ts +57 -39
- package/lib/latestMapValueManager.d.ts.map +1 -1
- package/lib/latestMapValueManager.js +47 -38
- package/lib/latestMapValueManager.js.map +1 -1
- package/lib/latestValueManager.d.ts +38 -20
- package/lib/latestValueManager.d.ts.map +1 -1
- package/lib/latestValueManager.js +31 -27
- package/lib/latestValueManager.js.map +1 -1
- package/lib/latestValueTypes.d.ts +9 -10
- package/lib/latestValueTypes.d.ts.map +1 -1
- package/lib/latestValueTypes.js.map +1 -1
- package/lib/notificationsManager.d.ts +15 -10
- package/lib/notificationsManager.d.ts.map +1 -1
- package/lib/notificationsManager.js +8 -5
- package/lib/notificationsManager.js.map +1 -1
- package/lib/presence.d.ts +82 -66
- package/lib/presence.d.ts.map +1 -1
- package/lib/presence.js +4 -4
- package/lib/presence.js.map +1 -1
- package/lib/presenceDatastoreManager.d.ts +12 -10
- package/lib/presenceDatastoreManager.d.ts.map +1 -1
- package/lib/presenceDatastoreManager.js +10 -8
- package/lib/presenceDatastoreManager.js.map +1 -1
- package/lib/presenceManager.d.ts +2 -2
- package/lib/presenceManager.d.ts.map +1 -1
- package/lib/presenceManager.js +14 -22
- package/lib/presenceManager.js.map +1 -1
- package/lib/presenceStates.d.ts +14 -13
- package/lib/presenceStates.d.ts.map +1 -1
- package/lib/presenceStates.js +22 -15
- package/lib/presenceStates.js.map +1 -1
- package/lib/stateDatastore.d.ts +5 -4
- package/lib/stateDatastore.d.ts.map +1 -1
- package/lib/stateDatastore.js.map +1 -1
- package/lib/stateFactory.d.ts +22 -0
- package/lib/stateFactory.d.ts.map +1 -0
- package/lib/stateFactory.js +22 -0
- package/lib/stateFactory.js.map +1 -0
- package/lib/systemWorkspace.d.ts +7 -7
- package/lib/systemWorkspace.d.ts.map +1 -1
- package/lib/systemWorkspace.js +24 -24
- package/lib/systemWorkspace.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/types.d.ts +50 -33
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +0 -1
- package/lib/types.js.map +1 -1
- package/package.json +19 -19
|
@@ -29,7 +29,7 @@ class NotificationsManagerImpl {
|
|
|
29
29
|
// This is a notification, so we want to send it immediately.
|
|
30
30
|
{ allowableUpdateLatencyMs: 0 });
|
|
31
31
|
},
|
|
32
|
-
unicast: (name,
|
|
32
|
+
unicast: (name, targetAttendee, ...args) => {
|
|
33
33
|
this.datastore.localUpdate(this.key, {
|
|
34
34
|
rev: 0,
|
|
35
35
|
timestamp: 0,
|
|
@@ -37,7 +37,7 @@ class NotificationsManagerImpl {
|
|
|
37
37
|
ignoreUnmonitored: true,
|
|
38
38
|
},
|
|
39
39
|
// This is a notification, so we want to send it immediately.
|
|
40
|
-
{ allowableUpdateLatencyMs: 0, targetClientId:
|
|
40
|
+
{ allowableUpdateLatencyMs: 0, targetClientId: targetAttendee.getConnectionId() });
|
|
41
41
|
},
|
|
42
42
|
};
|
|
43
43
|
// Workaround for types
|
|
@@ -58,17 +58,20 @@ class NotificationsManagerImpl {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
get presence() {
|
|
62
|
+
return this.datastore.presence;
|
|
63
|
+
}
|
|
64
|
+
update(attendee, _received, value) {
|
|
62
65
|
const postUpdateActions = [];
|
|
63
66
|
const eventName = value.value.name;
|
|
64
67
|
if (this.notificationsInternal.hasListeners(eventName)) {
|
|
65
68
|
// Without schema validation, we don't know that the args are the correct type.
|
|
66
69
|
// For now we assume the user is sending the correct types and there is no corruption along the way.
|
|
67
|
-
const args = [
|
|
70
|
+
const args = [attendee, ...value.value.args];
|
|
68
71
|
postUpdateActions.push(() => this.notificationsInternal.emit(eventName, ...args));
|
|
69
72
|
}
|
|
70
73
|
else {
|
|
71
|
-
postUpdateActions.push(() => this.events.emit("unattendedNotification", value.value.name,
|
|
74
|
+
postUpdateActions.push(() => this.events.emit("unattendedNotification", value.value.name, attendee, ...value.value.args));
|
|
72
75
|
}
|
|
73
76
|
return postUpdateActions;
|
|
74
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notificationsManager.js","sourceRoot":"","sources":["../src/notificationsManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA6D;AAQ7D,2DAA+E;AAC/E,uDAA6C;AA0I7C;;;GAGG;AACH,MAAM,UAAU,GAAG,MAAM,CAAC,IAAiE,CAAC;AAE5F,MAAM,wBAAwB;IA+C7B,YACkB,GAAQ,EACR,SAGhB,EACD,oBAA2D;QAL1C,QAAG,GAAH,GAAG,CAAK;QACR,cAAS,GAAT,SAAS,CAGzB;QA1Cc,WAAM,GAAG,IAAA,4BAAa,GAA8B,CAAC;QAErD,SAAI,GAA2B;YAC9C,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,IAAI,EAAE,EAAE;gBAC5B,IAAI,CAAC,SAAS,CAAC,WAAW,CACzB,IAAI,CAAC,GAAG,EACR;oBACC,GAAG,EAAE,CAAC;oBACN,SAAS,EAAE,CAAC;oBACZ,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,GAAI,IAA8B,CAAC,EAAE;oBAC3D,iB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pF,IAAI,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,CAAC;YACxD,+EAA+E;YAC/E,oGAAoG;YACpG,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAExC,CAAC;YACF,iBAAiB,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;QACnF,CAAC;aAAM,CAAC;YACP,iBAAiB,CAAC,IAAI,CAAC,GAAG,EAAE,CAC3B,IAAI,CAAC,MAAM,CAAC,IAAI,CACf,wBAAwB,EACxB,KAAK,CAAC,KAAK,CAAC,IAAI,EAChB,MAAM,EACN,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CACnB,CACD,CAAC;QACH,CAAC;QACD,OAAO,iBAAiB,CAAC;IAC1B,CAAC;CACD;AAED;;;;;;;;GAQG;AACH,SAAgB,aAAa,CAI5B,oBAA2D;IAM3D,MAAM,OAAO,GAAG,CACf,GAAQ,EACR,eAGC,EAGA,EAAE,CAAC,CAAC;QACL,OAAO,EAAE,IAAA,0BAAQ,EAKhB,IAAI,wBAAwB,CAC3B,GAAG,EACH,IAAA,uCAAmB,EAAC,eAAe,CAAC,EACpC,oBAAoB,CACpB,CACD;KACD,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,wBAAwB,EAAE,CAAC,CAAC;AAC3E,CAAC;AAhCD,sCAgCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { Listeners, Listenable, Off } from \"@fluidframework/core-interfaces\";\nimport type { JsonTypeWith } from \"@fluidframework/core-interfaces/internal\";\n\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { InternalUtilityTypes } from \"./exposedUtilityTypes.js\";\nimport type { PostUpdateAction, ValueManager } from \"./internalTypes.js\";\nimport type { ISessionClient } from \"./presence.js\";\nimport { datastoreFromHandle, type StateDatastore } from \"./stateDatastore.js\";\nimport { brandIVM } from \"./valueManager.js\";\n\n/**\n * @sealed\n * @alpha\n */\nexport interface NotificationsManagerEvents {\n\t/**\n\t * Raised when notification is received, but no subscribers were found.\n\t *\n\t * @eventProperty\n\t */\n\tunattendedNotification: (\n\t\tname: string,\n\t\tsender: ISessionClient,\n\t\t...content: unknown[]\n\t) => void;\n}\n\n/**\n * An object which allows the registration of listeners so that subscribers can be\n * notified when a notification happens.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationListenable<\n\tTListeners extends InternalUtilityTypes.NotificationListeners<TListeners>,\n> {\n\t/**\n\t * Register a notification listener.\n\t * @param notificationName - the name of the notification\n\t * @param listener - The listener function to run when the notification is fired.\n\t * @returns A {@link @fluidframework/core-interfaces#Off | function} which will deregister the listener when called.\n\t * Calling the deregistration function more than once will have no effect.\n\t *\n\t * Listeners may also be deregistered by passing the listener to {@link NotificationListenable.off | off()}.\n\t * @remarks Registering the exact same `listener` object for the same notification more than once will throw an error.\n\t * If registering the same listener for the same notification multiple times is desired, consider using a wrapper function for the second subscription.\n\t */\n\ton<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(\n\t\tnotificationName: K,\n\t\tlistener: (\n\t\t\tsender: ISessionClient,\n\t\t\t...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>\n\t\t) => void,\n\t): Off;\n\n\t/**\n\t * Deregister notification listener.\n\t * @param notificationName - The name of the notification.\n\t * @param listener - The listener function to remove from the current set of notification listeners.\n\t * @remarks If `listener` is not currently registered, this method will have no effect.\n\t *\n\t * Listeners may also be deregistered by calling the {@link @fluidframework/core-interfaces#Off | deregistration function} returned when they are {@link NotificationListenable.on | registered}.\n\t */\n\toff<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(\n\t\tnotificationName: K,\n\t\tlistener: (\n\t\t\tsender: ISessionClient,\n\t\t\t...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>\n\t\t) => void,\n\t): void;\n}\n\n/**\n * Record of notification subscriptions.\n *\n * @sealed\n * @alpha\n */\nexport type NotificationSubscriptions<\n\tE extends InternalUtilityTypes.NotificationListeners<E>,\n> = {\n\t[K in string & keyof InternalUtilityTypes.NotificationListeners<E>]: (\n\t\tsender: ISessionClient,\n\t\t...args: InternalUtilityTypes.JsonDeserializedParameters<E[K]>\n\t) => void;\n};\n\n/**\n * Interface for a notification emitter that can send typed notification to other clients.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationEmitter<E extends InternalUtilityTypes.NotificationListeners<E>> {\n\t/**\n\t * Emits a notification with the specified name and arguments, notifying all clients.\n\t * @param notificationName - the name of the notification to fire\n\t * @param args - the arguments sent with the notification\n\t */\n\tbroadcast<K extends string & keyof InternalUtilityTypes.NotificationListeners<E>>(\n\t\tnotificationName: K,\n\t\t...args: Parameters<E[K]>\n\t): void;\n\n\t/**\n\t * Emits a notification with the specified name and arguments, notifying a single client.\n\t * @param notificationName - the name of the notification to fire\n\t * @param targetClient - the single client to notify\n\t * @param args - the arguments sent with the notification\n\t */\n\tunicast<K extends string & keyof InternalUtilityTypes.NotificationListeners<E>>(\n\t\tnotificationName: K,\n\t\ttargetClient: ISessionClient,\n\t\t...args: Parameters<E[K]>\n\t): void;\n}\n\n/**\n * Value manager that provides notifications from this client to others and subscription\n * to their notifications.\n *\n * @remarks Create using {@link Notifications} registered to {@link PresenceStates}.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationsManager<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n> {\n\t/**\n\t * Events for Notifications manager.\n\t */\n\treadonly events: Listenable<NotificationsManagerEvents>;\n\n\t/**\n\t * Send notifications to other clients.\n\t */\n\treadonly emit: NotificationEmitter<T>;\n\n\t/**\n\t * Provides subscription to notifications from other clients.\n\t */\n\treadonly notifications: NotificationListenable<T>;\n}\n\n/**\n * Object.keys retyped to support specific records keys and\n * branded string-based keys.\n */\nconst recordKeys = Object.keys as <K extends string>(o: Partial<Record<K, unknown>>) => K[];\n\nclass NotificationsManagerImpl<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n\tKey extends string,\n> implements\n\t\tNotificationsManager<T>,\n\t\tValueManager<\n\t\t\tInternalTypes.NotificationType,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>\n{\n\tpublic readonly events = createEmitter<NotificationsManagerEvents>();\n\n\tpublic readonly emit: NotificationEmitter<T> = {\n\t\tbroadcast: (name, ...args) => {\n\t\t\tthis.datastore.localUpdate(\n\t\t\t\tthis.key,\n\t\t\t\t{\n\t\t\t\t\trev: 0,\n\t\t\t\t\ttimestamp: 0,\n\t\t\t\t\tvalue: { name, args: [...(args as JsonTypeWith<never>[])] },\n\t\t\t\t\tignoreUnmonitored: true,\n\t\t\t\t},\n\t\t\t\t// This is a notification, so we want to send it immediately.\n\t\t\t\t{ allowableUpdateLatencyMs: 0 },\n\t\t\t);\n\t\t},\n\t\tunicast: (name, targetClient, ...args) => {\n\t\t\tthis.datastore.localUpdate(\n\t\t\t\tthis.key,\n\t\t\t\t{\n\t\t\t\t\trev: 0,\n\t\t\t\t\ttimestamp: 0,\n\t\t\t\t\tvalue: { name, args: [...(args as JsonTypeWith<never>[])] },\n\t\t\t\t\tignoreUnmonitored: true,\n\t\t\t\t},\n\t\t\t\t// This is a notification, so we want to send it immediately.\n\t\t\t\t{ allowableUpdateLatencyMs: 0, targetClientId: targetClient.getConnectionId() },\n\t\t\t);\n\t\t},\n\t};\n\n\t// Workaround for types\n\tprivate readonly notificationsInternal = createEmitter<NotificationSubscriptions<T>>();\n\n\t// @ts-expect-error TODO\n\tpublic readonly notifications: NotificationListenable<T> = this.notificationsInternal;\n\n\tpublic constructor(\n\t\tprivate readonly key: Key,\n\t\tprivate readonly datastore: StateDatastore<\n\t\t\tKey,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>,\n\t\tinitialSubscriptions: Partial<NotificationSubscriptions<T>>,\n\t) {\n\t\t// Add event listeners provided at instantiation\n\t\tfor (const subscriptionName of recordKeys(initialSubscriptions)) {\n\t\t\t// Lingering Event typing issues with Notifications specialization requires\n\t\t\t// this cast. The only thing that really matters is that name is a string.\n\t\t\tconst name = subscriptionName as keyof Listeners<NotificationSubscriptions<T>>;\n\t\t\tconst value = initialSubscriptions[subscriptionName];\n\t\t\t// This check should not be needed while using exactOptionalPropertyTypes, but\n\t\t\t// typescript appears to ignore that with Partial<>. Good to be defensive\n\t\t\t// against callers sending `undefined` anyway.\n\t\t\tif (value !== undefined) {\n\t\t\t\tthis.notificationsInternal.on(name, value);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic update(\n\t\tclient: ISessionClient,\n\t\t_received: number,\n\t\tvalue: InternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\t): PostUpdateAction[] {\n\t\tconst postUpdateActions: PostUpdateAction[] = [];\n\t\tconst eventName = value.value.name as keyof Listeners<NotificationSubscriptions<T>>;\n\t\tif (this.notificationsInternal.hasListeners(eventName)) {\n\t\t\t// Without schema validation, we don't know that the args are the correct type.\n\t\t\t// For now we assume the user is sending the correct types and there is no corruption along the way.\n\t\t\tconst args = [client, ...value.value.args] as Parameters<\n\t\t\t\tNotificationSubscriptions<T>[typeof eventName]\n\t\t\t>;\n\t\t\tpostUpdateActions.push(() => this.notificationsInternal.emit(eventName, ...args));\n\t\t} else {\n\t\t\tpostUpdateActions.push(() =>\n\t\t\t\tthis.events.emit(\n\t\t\t\t\t\"unattendedNotification\",\n\t\t\t\t\tvalue.value.name,\n\t\t\t\t\tclient,\n\t\t\t\t\t...value.value.args,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\treturn postUpdateActions;\n\t}\n}\n\n/**\n * Factory for creating a {@link NotificationsManager}.\n *\n * @remarks\n * Typescript inference for `Notifications` is not working correctly yet.\n * Explicitly specify generics to make result types usable.\n *\n * @alpha\n */\nexport function Notifications<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n\tKey extends string = string,\n>(\n\tinitialSubscriptions: Partial<NotificationSubscriptions<T>>,\n): InternalTypes.ManagerFactory<\n\tKey,\n\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\tNotificationsManager<T>\n> {\n\tconst factory = (\n\t\tkey: Key,\n\t\tdatastoreHandle: InternalTypes.StateDatastoreHandle<\n\t\t\tKey,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>,\n\t): {\n\t\tmanager: InternalTypes.StateValue<NotificationsManager<T>>;\n\t} => ({\n\t\tmanager: brandIVM<\n\t\t\tNotificationsManagerImpl<T, Key>,\n\t\t\tInternalTypes.NotificationType,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>(\n\t\t\tnew NotificationsManagerImpl(\n\t\t\t\tkey,\n\t\t\t\tdatastoreFromHandle(datastoreHandle),\n\t\t\t\tinitialSubscriptions,\n\t\t\t),\n\t\t),\n\t});\n\treturn Object.assign(factory, { instanceBase: NotificationsManagerImpl });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"notificationsManager.js","sourceRoot":"","sources":["../src/notificationsManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA6D;AAQ7D,2DAA+E;AAC/E,uDAA6C;AA4I7C;;;GAGG;AACH,MAAM,UAAU,GAAG,MAAM,CAAC,IAAiE,CAAC;AAE5F,MAAM,wBAAwB;IA+C7B,YACkB,GAAQ,EACR,SAGhB,EACD,oBAA2D;QAL1C,QAAG,GAAH,GAAG,CAAK;QACR,cAAS,GAAT,SAAS,CAGzB;QA1Cc,WAAM,GAAG,IAAA,4BAAa,GAA8B,CAAC;QAErD,SAAI,GAA2B;YAC9C,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,IAAI,EAAE,EAAE;gBAC5B,IAAI,CAA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C;AAC3E,CAAC;AAhCD,sCAgCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { Listeners, Listenable, Off } from \"@fluidframework/core-interfaces\";\nimport type { JsonTypeWith } from \"@fluidframework/core-interfaces/internal\";\n\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { InternalUtilityTypes } from \"./exposedUtilityTypes.js\";\nimport type { PostUpdateAction, ValueManager } from \"./internalTypes.js\";\nimport type { Attendee, Presence } from \"./presence.js\";\nimport { datastoreFromHandle, type StateDatastore } from \"./stateDatastore.js\";\nimport { brandIVM } from \"./valueManager.js\";\n\n/**\n * @sealed\n * @alpha\n */\nexport interface NotificationsManagerEvents {\n\t/**\n\t * Raised when notification is received, but no subscribers were found.\n\t *\n\t * @eventProperty\n\t */\n\tunattendedNotification: (name: string, sender: Attendee, ...content: unknown[]) => void;\n}\n\n/**\n * An object which allows the registration of listeners so that subscribers can be\n * notified when a notification happens.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationListenable<\n\tTListeners extends InternalUtilityTypes.NotificationListeners<TListeners>,\n> {\n\t/**\n\t * Register a notification listener.\n\t * @param notificationName - the name of the notification\n\t * @param listener - The listener function to run when the notification is fired.\n\t * @returns A {@link @fluidframework/core-interfaces#Off | function} which will deregister the listener when called.\n\t * Calling the deregistration function more than once will have no effect.\n\t *\n\t * Listeners may also be deregistered by passing the listener to {@link NotificationListenable.off | off()}.\n\t * @remarks Registering the exact same `listener` object for the same notification more than once will throw an error.\n\t * If registering the same listener for the same notification multiple times is desired, consider using a wrapper function for the second subscription.\n\t */\n\ton<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(\n\t\tnotificationName: K,\n\t\tlistener: (\n\t\t\tsender: Attendee,\n\t\t\t...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>\n\t\t) => void,\n\t): Off;\n\n\t/**\n\t * Deregister notification listener.\n\t * @param notificationName - The name of the notification.\n\t * @param listener - The listener function to remove from the current set of notification listeners.\n\t * @remarks If `listener` is not currently registered, this method will have no effect.\n\t *\n\t * Listeners may also be deregistered by calling the {@link @fluidframework/core-interfaces#Off | deregistration function} returned when they are {@link NotificationListenable.on | registered}.\n\t */\n\toff<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(\n\t\tnotificationName: K,\n\t\tlistener: (\n\t\t\tsender: Attendee,\n\t\t\t...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>\n\t\t) => void,\n\t): void;\n}\n\n/**\n * Record of notification subscriptions.\n *\n * @sealed\n * @alpha\n */\nexport type NotificationSubscriptions<\n\tE extends InternalUtilityTypes.NotificationListeners<E>,\n> = {\n\t[K in string & keyof InternalUtilityTypes.NotificationListeners<E>]: (\n\t\tsender: Attendee,\n\t\t...args: InternalUtilityTypes.JsonDeserializedParameters<E[K]>\n\t) => void;\n};\n\n/**\n * Interface for a notification emitter that can send typed notification to other clients.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationEmitter<E extends InternalUtilityTypes.NotificationListeners<E>> {\n\t/**\n\t * Emits a notification with the specified name and arguments, notifying all clients.\n\t * @param notificationName - the name of the notification to fire\n\t * @param args - the arguments sent with the notification\n\t */\n\tbroadcast<K extends string & keyof InternalUtilityTypes.NotificationListeners<E>>(\n\t\tnotificationName: K,\n\t\t...args: Parameters<E[K]>\n\t): void;\n\n\t/**\n\t * Emits a notification with the specified name and arguments, notifying a single attendee.\n\t * @param notificationName - the name of the notification to fire\n\t * @param targetAttendee - the single attendee to notify\n\t * @param args - the arguments sent with the notification\n\t */\n\tunicast<K extends string & keyof InternalUtilityTypes.NotificationListeners<E>>(\n\t\tnotificationName: K,\n\t\ttargetAttendee: Attendee,\n\t\t...args: Parameters<E[K]>\n\t): void;\n}\n\n/**\n * Provides notifications from this client to others and subscription\n * to their notifications.\n *\n * @remarks Create using {@link Notifications} registered to\n * {@link NotificationsWorkspace} or {@link StatesWorkspace}.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationsManager<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n> {\n\t/**\n\t * Containing {@link Presence}\n\t */\n\treadonly presence: Presence;\n\n\t/**\n\t * Events for Notifications manager.\n\t */\n\treadonly events: Listenable<NotificationsManagerEvents>;\n\n\t/**\n\t * Send notifications to other clients.\n\t */\n\treadonly emit: NotificationEmitter<T>;\n\n\t/**\n\t * Provides subscription to notifications from other clients.\n\t */\n\treadonly notifications: NotificationListenable<T>;\n}\n\n/**\n * Object.keys retyped to support specific records keys and\n * branded string-based keys.\n */\nconst recordKeys = Object.keys as <K extends string>(o: Partial<Record<K, unknown>>) => K[];\n\nclass NotificationsManagerImpl<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n\tKey extends string,\n> implements\n\t\tNotificationsManager<T>,\n\t\tValueManager<\n\t\t\tInternalTypes.NotificationType,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>\n{\n\tpublic readonly events = createEmitter<NotificationsManagerEvents>();\n\n\tpublic readonly emit: NotificationEmitter<T> = {\n\t\tbroadcast: (name, ...args) => {\n\t\t\tthis.datastore.localUpdate(\n\t\t\t\tthis.key,\n\t\t\t\t{\n\t\t\t\t\trev: 0,\n\t\t\t\t\ttimestamp: 0,\n\t\t\t\t\tvalue: { name, args: [...(args as JsonTypeWith<never>[])] },\n\t\t\t\t\tignoreUnmonitored: true,\n\t\t\t\t},\n\t\t\t\t// This is a notification, so we want to send it immediately.\n\t\t\t\t{ allowableUpdateLatencyMs: 0 },\n\t\t\t);\n\t\t},\n\t\tunicast: (name, targetAttendee, ...args) => {\n\t\t\tthis.datastore.localUpdate(\n\t\t\t\tthis.key,\n\t\t\t\t{\n\t\t\t\t\trev: 0,\n\t\t\t\t\ttimestamp: 0,\n\t\t\t\t\tvalue: { name, args: [...(args as JsonTypeWith<never>[])] },\n\t\t\t\t\tignoreUnmonitored: true,\n\t\t\t\t},\n\t\t\t\t// This is a notification, so we want to send it immediately.\n\t\t\t\t{ allowableUpdateLatencyMs: 0, targetClientId: targetAttendee.getConnectionId() },\n\t\t\t);\n\t\t},\n\t};\n\n\t// Workaround for types\n\tprivate readonly notificationsInternal = createEmitter<NotificationSubscriptions<T>>();\n\n\t// @ts-expect-error TODO\n\tpublic readonly notifications: NotificationListenable<T> = this.notificationsInternal;\n\n\tpublic constructor(\n\t\tprivate readonly key: Key,\n\t\tprivate readonly datastore: StateDatastore<\n\t\t\tKey,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>,\n\t\tinitialSubscriptions: Partial<NotificationSubscriptions<T>>,\n\t) {\n\t\t// Add event listeners provided at instantiation\n\t\tfor (const subscriptionName of recordKeys(initialSubscriptions)) {\n\t\t\t// Lingering Event typing issues with Notifications specialization requires\n\t\t\t// this cast. The only thing that really matters is that name is a string.\n\t\t\tconst name = subscriptionName as keyof Listeners<NotificationSubscriptions<T>>;\n\t\t\tconst value = initialSubscriptions[subscriptionName];\n\t\t\t// This check should not be needed while using exactOptionalPropertyTypes, but\n\t\t\t// typescript appears to ignore that with Partial<>. Good to be defensive\n\t\t\t// against callers sending `undefined` anyway.\n\t\t\tif (value !== undefined) {\n\t\t\t\tthis.notificationsInternal.on(name, value);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic get presence(): Presence {\n\t\treturn this.datastore.presence;\n\t}\n\n\tpublic update(\n\t\tattendee: Attendee,\n\t\t_received: number,\n\t\tvalue: InternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\t): PostUpdateAction[] {\n\t\tconst postUpdateActions: PostUpdateAction[] = [];\n\t\tconst eventName = value.value.name as keyof Listeners<NotificationSubscriptions<T>>;\n\t\tif (this.notificationsInternal.hasListeners(eventName)) {\n\t\t\t// Without schema validation, we don't know that the args are the correct type.\n\t\t\t// For now we assume the user is sending the correct types and there is no corruption along the way.\n\t\t\tconst args = [attendee, ...value.value.args] as Parameters<\n\t\t\t\tNotificationSubscriptions<T>[typeof eventName]\n\t\t\t>;\n\t\t\tpostUpdateActions.push(() => this.notificationsInternal.emit(eventName, ...args));\n\t\t} else {\n\t\t\tpostUpdateActions.push(() =>\n\t\t\t\tthis.events.emit(\n\t\t\t\t\t\"unattendedNotification\",\n\t\t\t\t\tvalue.value.name,\n\t\t\t\t\tattendee,\n\t\t\t\t\t...value.value.args,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\treturn postUpdateActions;\n\t}\n}\n\n/**\n * Factory for creating a {@link NotificationsManager}.\n *\n * @remarks\n * Typescript inference for `Notifications` is not working correctly yet.\n * Explicitly specify generics to make result types usable.\n *\n * @alpha\n */\nexport function Notifications<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n\tKey extends string = string,\n>(\n\tinitialSubscriptions: Partial<NotificationSubscriptions<T>>,\n): InternalTypes.ManagerFactory<\n\tKey,\n\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\tNotificationsManager<T>\n> {\n\tconst factory = (\n\t\tkey: Key,\n\t\tdatastoreHandle: InternalTypes.StateDatastoreHandle<\n\t\t\tKey,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>,\n\t): {\n\t\tmanager: InternalTypes.StateValue<NotificationsManager<T>>;\n\t} => ({\n\t\tmanager: brandIVM<\n\t\t\tNotificationsManagerImpl<T, Key>,\n\t\t\tInternalTypes.NotificationType,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>(\n\t\t\tnew NotificationsManagerImpl(\n\t\t\t\tkey,\n\t\t\t\tdatastoreFromHandle(datastoreHandle),\n\t\t\t\tinitialSubscriptions,\n\t\t\t),\n\t\t),\n\t});\n\treturn Object.assign(factory, { instanceBase: NotificationsManagerImpl });\n}\n"]}
|
package/dist/presence.d.ts
CHANGED
|
@@ -6,42 +6,42 @@ import type { Listenable } from "@fluidframework/core-interfaces";
|
|
|
6
6
|
import type { SessionId } from "@fluidframework/id-compressor";
|
|
7
7
|
import type { ClientConnectionId } from "./baseTypes.js";
|
|
8
8
|
import type { BroadcastControlSettings } from "./broadcastControls.js";
|
|
9
|
-
import type {
|
|
9
|
+
import type { NotificationsWorkspace, NotificationsWorkspaceSchema, StatesWorkspace, StatesWorkspaceSchema, WorkspaceAddress } from "./types.js";
|
|
10
10
|
/**
|
|
11
11
|
* A Fluid client session identifier.
|
|
12
12
|
*
|
|
13
13
|
* @remarks
|
|
14
14
|
* Each client once connected to a session is given a unique identifier for the
|
|
15
15
|
* duration of the session. If a client disconnects and reconnects, it will
|
|
16
|
-
* retain its identifier. Prefer use of {@link
|
|
17
|
-
* identify clients in a session. {@link
|
|
16
|
+
* retain its identifier. Prefer use of {@link Attendee} as a way to
|
|
17
|
+
* identify clients in a session. {@link Attendee.attendeeId} will provide
|
|
18
18
|
* the session ID.
|
|
19
19
|
*
|
|
20
20
|
* @alpha
|
|
21
21
|
*/
|
|
22
|
-
export type
|
|
23
|
-
readonly
|
|
22
|
+
export type AttendeeId = SessionId & {
|
|
23
|
+
readonly AttendeeId: "AttendeeId";
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
|
-
* The connection status of the {@link
|
|
26
|
+
* The connection status of the {@link Attendee}.
|
|
27
27
|
*
|
|
28
28
|
* @alpha
|
|
29
29
|
*/
|
|
30
|
-
export declare const
|
|
30
|
+
export declare const AttendeeStatus: {
|
|
31
31
|
/**
|
|
32
|
-
* The
|
|
32
|
+
* The {@link Attendee} is connected to the Fluid service.
|
|
33
33
|
*/
|
|
34
34
|
readonly Connected: "Connected";
|
|
35
35
|
/**
|
|
36
|
-
* The
|
|
36
|
+
* The {@link Attendee} is not connected to the Fluid service.
|
|
37
37
|
*/
|
|
38
38
|
readonly Disconnected: "Disconnected";
|
|
39
39
|
};
|
|
40
40
|
/**
|
|
41
|
-
* Represents the connection status of an {@link
|
|
41
|
+
* Represents the connection status of an {@link Attendee}.
|
|
42
42
|
*
|
|
43
43
|
* This type can be either `'Connected'` or `'Disconnected'`, indicating whether
|
|
44
|
-
* the
|
|
44
|
+
* the attendee is currently connected to the Fluid service.
|
|
45
45
|
*
|
|
46
46
|
* When `'Disconnected'`:
|
|
47
47
|
* - State changes are kept locally and communicated to others upon reconnect.
|
|
@@ -49,17 +49,17 @@ export declare const SessionClientStatus: {
|
|
|
49
49
|
*
|
|
50
50
|
* @alpha
|
|
51
51
|
*/
|
|
52
|
-
export type
|
|
52
|
+
export type AttendeeStatus = (typeof AttendeeStatus)[keyof typeof AttendeeStatus];
|
|
53
53
|
/**
|
|
54
54
|
* A client within a Fluid session (period of container connectivity to service).
|
|
55
55
|
*
|
|
56
56
|
* @remarks
|
|
57
|
-
* Note: This is very preliminary
|
|
57
|
+
* Note: This is very preliminary attendee representation.
|
|
58
58
|
*
|
|
59
|
-
*
|
|
59
|
+
* {@link Attendee} should be used as key to distinguish between different
|
|
60
60
|
* clients as they join, rejoin, and disconnect from a session. While a
|
|
61
|
-
* client's {@link ClientConnectionId} from {@link
|
|
62
|
-
* may change over time, `
|
|
61
|
+
* client's {@link ClientConnectionId} from {@link Attendee.getConnectionStatus}
|
|
62
|
+
* may change over time, `Attendee` will be fixed.
|
|
63
63
|
*
|
|
64
64
|
* @privateRemarks
|
|
65
65
|
* As this is evolved, pay attention to how this relates to Audience, Service
|
|
@@ -68,11 +68,11 @@ export type SessionClientStatus = (typeof SessionClientStatus)[keyof typeof Sess
|
|
|
68
68
|
* @sealed
|
|
69
69
|
* @alpha
|
|
70
70
|
*/
|
|
71
|
-
export interface
|
|
71
|
+
export interface Attendee<SpecificAttendeeId extends AttendeeId = AttendeeId> {
|
|
72
72
|
/**
|
|
73
73
|
* The session ID of the client that is stable over all connections.
|
|
74
74
|
*/
|
|
75
|
-
readonly
|
|
75
|
+
readonly attendeeId: SpecificAttendeeId;
|
|
76
76
|
/**
|
|
77
77
|
* Get current client connection ID.
|
|
78
78
|
*
|
|
@@ -81,41 +81,47 @@ export interface ISessionClient<SpecificSessionClientId extends ClientSessionId
|
|
|
81
81
|
* @remarks
|
|
82
82
|
* Connection ID will change on reconnect.
|
|
83
83
|
*
|
|
84
|
-
* If {@link
|
|
84
|
+
* If {@link Attendee.getConnectionStatus} is {@link (AttendeeStatus:variable).Disconnected}, this will represent the last known connection ID.
|
|
85
85
|
*/
|
|
86
86
|
getConnectionId(): ClientConnectionId;
|
|
87
87
|
/**
|
|
88
|
-
* Get connection status of
|
|
88
|
+
* Get connection status of attendee.
|
|
89
89
|
*
|
|
90
|
-
* @returns Connection status of
|
|
90
|
+
* @returns Connection status of attendee.
|
|
91
91
|
*
|
|
92
92
|
*/
|
|
93
|
-
getConnectionStatus():
|
|
93
|
+
getConnectionStatus(): AttendeeStatus;
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
|
-
* Utility type limiting to a specific
|
|
96
|
+
* Utility type limiting to a specific attendee. (A attendee with
|
|
97
97
|
* a specific session ID - not just any session ID.)
|
|
98
98
|
*
|
|
99
99
|
* @internal
|
|
100
100
|
*/
|
|
101
|
-
export type
|
|
101
|
+
export type SpecificAttendee<SpecificAttendeeId extends AttendeeId> = string extends SpecificAttendeeId ? never : Attendee<SpecificAttendeeId>;
|
|
102
102
|
/**
|
|
103
103
|
* @sealed
|
|
104
104
|
* @alpha
|
|
105
105
|
*/
|
|
106
|
-
export interface
|
|
106
|
+
export interface AttendeesEvents {
|
|
107
107
|
/**
|
|
108
108
|
* Raised when new client joins session.
|
|
109
109
|
*
|
|
110
110
|
* @eventProperty
|
|
111
111
|
*/
|
|
112
|
-
|
|
112
|
+
attendeeConnected: (attendee: Attendee) => void;
|
|
113
113
|
/**
|
|
114
114
|
* Raised when client appears disconnected from session.
|
|
115
115
|
*
|
|
116
116
|
* @eventProperty
|
|
117
117
|
*/
|
|
118
|
-
attendeeDisconnected: (attendee:
|
|
118
|
+
attendeeDisconnected: (attendee: Attendee) => void;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* @sealed
|
|
122
|
+
* @alpha
|
|
123
|
+
*/
|
|
124
|
+
export interface PresenceEvents {
|
|
119
125
|
/**
|
|
120
126
|
* Raised when a workspace is activated within the session.
|
|
121
127
|
*
|
|
@@ -128,7 +134,7 @@ export interface PresenceEvents {
|
|
|
128
134
|
* be done before the event handler returns to ensure no notifications
|
|
129
135
|
* are missed.
|
|
130
136
|
*/
|
|
131
|
-
workspaceActivated: (workspaceAddress:
|
|
137
|
+
workspaceActivated: (workspaceAddress: WorkspaceAddress, type: "States" | "Notifications" | "Unknown") => void;
|
|
132
138
|
}
|
|
133
139
|
/**
|
|
134
140
|
* Presence represents known clients within a session and their custom states and notifications.
|
|
@@ -136,47 +142,57 @@ export interface PresenceEvents {
|
|
|
136
142
|
* @sealed
|
|
137
143
|
* @alpha
|
|
138
144
|
*/
|
|
139
|
-
export interface
|
|
145
|
+
export interface Presence {
|
|
140
146
|
/**
|
|
141
147
|
* Events for Presence.
|
|
142
148
|
*/
|
|
143
149
|
readonly events: Listenable<PresenceEvents>;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
150
|
+
readonly attendees: {
|
|
151
|
+
/**
|
|
152
|
+
* Events for {@link Attendee}s.
|
|
153
|
+
*/
|
|
154
|
+
readonly events: Listenable<AttendeesEvents>;
|
|
155
|
+
/**
|
|
156
|
+
* Get all {@link Attendee}s in the session.
|
|
157
|
+
*
|
|
158
|
+
* @remarks
|
|
159
|
+
* Attendee states are dynamic and will change as clients join and leave
|
|
160
|
+
* the session.
|
|
161
|
+
*/
|
|
162
|
+
getAttendees(): ReadonlySet<Attendee>;
|
|
163
|
+
/**
|
|
164
|
+
* Lookup a specific {@link Attendee} in the session.
|
|
165
|
+
*
|
|
166
|
+
* @param clientId - Client connection or session ID
|
|
167
|
+
*/
|
|
168
|
+
getAttendee(clientId: ClientConnectionId | AttendeeId): Attendee;
|
|
169
|
+
/**
|
|
170
|
+
* Get this client's {@link Attendee}.
|
|
171
|
+
*
|
|
172
|
+
* @returns This client's attendee.
|
|
173
|
+
*/
|
|
174
|
+
getMyself(): Attendee;
|
|
175
|
+
};
|
|
176
|
+
readonly states: {
|
|
177
|
+
/**
|
|
178
|
+
* Acquires a StatesWorkspace from store or adds new one.
|
|
179
|
+
*
|
|
180
|
+
* @param workspaceAddress - Address of the requested StatesWorkspace
|
|
181
|
+
* @param requestedStates - Requested states for the workspace
|
|
182
|
+
* @param controls - Optional settings for default broadcast controls
|
|
183
|
+
* @returns A StatesWorkspace
|
|
184
|
+
*/
|
|
185
|
+
getWorkspace<StatesSchema extends StatesWorkspaceSchema>(workspaceAddress: WorkspaceAddress, requestedStates: StatesSchema, controls?: BroadcastControlSettings): StatesWorkspace<StatesSchema>;
|
|
186
|
+
};
|
|
187
|
+
readonly notifications: {
|
|
188
|
+
/**
|
|
189
|
+
* Acquires a Notifications workspace from store or adds new one.
|
|
190
|
+
*
|
|
191
|
+
* @param workspaceAddress - Address of the requested Notifications Workspace
|
|
192
|
+
* @param requestedNotifications - Requested notifications for the workspace
|
|
193
|
+
* @returns A Notifications workspace
|
|
194
|
+
*/
|
|
195
|
+
getWorkspace<NotificationsSchema extends NotificationsWorkspaceSchema>(notificationsId: WorkspaceAddress, requestedNotifications: NotificationsSchema): NotificationsWorkspace<NotificationsSchema>;
|
|
196
|
+
};
|
|
181
197
|
}
|
|
182
198
|
//# sourceMappingURL=presence.d.ts.map
|
package/dist/presence.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presence.d.ts","sourceRoot":"","sources":["../src/presence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,EACX,
|
|
1
|
+
{"version":3,"file":"presence.d.ts","sourceRoot":"","sources":["../src/presence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,EACX,sBAAsB,EACtB,4BAA4B,EAC5B,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAA;CAAE,CAAC;AAE3E;;;;GAIG;AACH,eAAO,MAAM,cAAc;IAC1B;;OAEG;;IAGH;;OAEG;;CAEM,CAAC;AAEX;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAElF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,QAAQ,CAAC,kBAAkB,SAAS,UAAU,GAAG,UA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AgB,EAAE,gBAAgB,EAClC,eAAe,EAAE,YAAY,EAC7B,QAAQ,CAAC,EAAE,wBAAwB,GACjC,eAAe,CAAC,YAAY,CAAC,CAAC;KACjC,CAAC;IAEF,QAAQ,CAAC,aAAa,EAAE;QACvB;;;;;;WAMG;QACH,YAAY,CAAC,mBAAmB,SAAS,4BAA4B,EACpE,eAAe,EAAE,gBAAgB,EACjC,sBAAsB,EAAE,mBAAmB,GACzC,sBAAsB,CAAC,mBAAmB,CAAC,CAAC;KAC/C,CAAC;CACF"}
|
package/dist/presence.js
CHANGED
|
@@ -4,19 +4,19 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.AttendeeStatus = void 0;
|
|
8
8
|
/**
|
|
9
|
-
* The connection status of the {@link
|
|
9
|
+
* The connection status of the {@link Attendee}.
|
|
10
10
|
*
|
|
11
11
|
* @alpha
|
|
12
12
|
*/
|
|
13
|
-
exports.
|
|
13
|
+
exports.AttendeeStatus = {
|
|
14
14
|
/**
|
|
15
|
-
* The
|
|
15
|
+
* The {@link Attendee} is connected to the Fluid service.
|
|
16
16
|
*/
|
|
17
17
|
Connected: "Connected",
|
|
18
18
|
/**
|
|
19
|
-
* The
|
|
19
|
+
* The {@link Attendee} is not connected to the Fluid service.
|
|
20
20
|
*/
|
|
21
21
|
Disconnected: "Disconnected",
|
|
22
22
|
};
|
package/dist/presence.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presence.js","sourceRoot":"","sources":["../src/presence.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA6BH;;;;GAIG;AACU,QAAA,
|
|
1
|
+
{"version":3,"file":"presence.js","sourceRoot":"","sources":["../src/presence.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA6BH;;;;GAIG;AACU,QAAA,cAAc,GAAG;IAC7B;;OAEG;IACH,SAAS,EAAE,WAAW;IAEtB;;OAEG;IACH,YAAY,EAAE,cAAc;CACnB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Listenable } from \"@fluidframework/core-interfaces\";\nimport type { SessionId } from \"@fluidframework/id-compressor\";\n\nimport type { ClientConnectionId } from \"./baseTypes.js\";\nimport type { BroadcastControlSettings } from \"./broadcastControls.js\";\nimport type {\n\tNotificationsWorkspace,\n\tNotificationsWorkspaceSchema,\n\tStatesWorkspace,\n\tStatesWorkspaceSchema,\n\tWorkspaceAddress,\n} from \"./types.js\";\n\n/**\n * A Fluid client session identifier.\n *\n * @remarks\n * Each client once connected to a session is given a unique identifier for the\n * duration of the session. If a client disconnects and reconnects, it will\n * retain its identifier. Prefer use of {@link Attendee} as a way to\n * identify clients in a session. {@link Attendee.attendeeId} will provide\n * the session ID.\n *\n * @alpha\n */\nexport type AttendeeId = SessionId & { readonly AttendeeId: \"AttendeeId\" };\n\n/**\n * The connection status of the {@link Attendee}.\n *\n * @alpha\n */\nexport const AttendeeStatus = {\n\t/**\n\t * The {@link Attendee} is connected to the Fluid service.\n\t */\n\tConnected: \"Connected\",\n\n\t/**\n\t * The {@link Attendee} is not connected to the Fluid service.\n\t */\n\tDisconnected: \"Disconnected\",\n} as const;\n\n/**\n * Represents the connection status of an {@link Attendee}.\n *\n * This type can be either `'Connected'` or `'Disconnected'`, indicating whether\n * the attendee is currently connected to the Fluid service.\n *\n * When `'Disconnected'`:\n * - State changes are kept locally and communicated to others upon reconnect.\n * - Notification requests are discarded (silently).\n *\n * @alpha\n */\nexport type AttendeeStatus = (typeof AttendeeStatus)[keyof typeof AttendeeStatus];\n\n/**\n * A client within a Fluid session (period of container connectivity to service).\n *\n * @remarks\n * Note: This is very preliminary attendee representation.\n *\n * {@link Attendee} should be used as key to distinguish between different\n * clients as they join, rejoin, and disconnect from a session. While a\n * client's {@link ClientConnectionId} from {@link Attendee.getConnectionStatus}\n * may change over time, `Attendee` will be fixed.\n *\n * @privateRemarks\n * As this is evolved, pay attention to how this relates to Audience, Service\n * Audience, and Quorum representations of clients and users.\n *\n * @sealed\n * @alpha\n */\nexport interface Attendee<SpecificAttendeeId extends AttendeeId = AttendeeId> {\n\t/**\n\t * The session ID of the client that is stable over all connections.\n\t */\n\treadonly attendeeId: SpecificAttendeeId;\n\n\t/**\n\t * Get current client connection ID.\n\t *\n\t * @returns Current client connection ID.\n\t *\n\t * @remarks\n\t * Connection ID will change on reconnect.\n\t *\n\t * If {@link Attendee.getConnectionStatus} is {@link (AttendeeStatus:variable).Disconnected}, this will represent the last known connection ID.\n\t */\n\tgetConnectionId(): ClientConnectionId;\n\n\t/**\n\t * Get connection status of attendee.\n\t *\n\t * @returns Connection status of attendee.\n\t *\n\t */\n\tgetConnectionStatus(): AttendeeStatus;\n}\n\n/**\n * Utility type limiting to a specific attendee. (A attendee with\n * a specific session ID - not just any session ID.)\n *\n * @internal\n */\nexport type SpecificAttendee<SpecificAttendeeId extends AttendeeId> =\n\tstring extends SpecificAttendeeId ? never : Attendee<SpecificAttendeeId>;\n\n/**\n * @sealed\n * @alpha\n */\nexport interface AttendeesEvents {\n\t/**\n\t * Raised when new client joins session.\n\t *\n\t * @eventProperty\n\t */\n\tattendeeConnected: (attendee: Attendee) => void;\n\n\t/**\n\t * Raised when client appears disconnected from session.\n\t *\n\t * @eventProperty\n\t */\n\tattendeeDisconnected: (attendee: Attendee) => void;\n}\n\n/**\n * @sealed\n * @alpha\n */\nexport interface PresenceEvents {\n\t/**\n\t * Raised when a workspace is activated within the session.\n\t *\n\t * \"Activated\" means that a workspace is being used by a client and this\n\t * client is seeing information for the first time.\n\t *\n\t * @remarks\n\t * Local workspaces may be passively acquired/registered when this event\n\t * is raised. For a notifications workspace, that lazy registration must\n\t * be done before the event handler returns to ensure no notifications\n\t * are missed.\n\t */\n\tworkspaceActivated: (\n\t\tworkspaceAddress: WorkspaceAddress,\n\t\ttype: \"States\" | \"Notifications\" | \"Unknown\",\n\t) => void;\n}\n\n/**\n * Presence represents known clients within a session and their custom states and notifications.\n *\n * @sealed\n * @alpha\n */\nexport interface Presence {\n\t/**\n\t * Events for Presence.\n\t */\n\treadonly events: Listenable<PresenceEvents>;\n\n\treadonly attendees: {\n\t\t/**\n\t\t * Events for {@link Attendee}s.\n\t\t */\n\t\treadonly events: Listenable<AttendeesEvents>;\n\n\t\t/**\n\t\t * Get all {@link Attendee}s in the session.\n\t\t *\n\t\t * @remarks\n\t\t * Attendee states are dynamic and will change as clients join and leave\n\t\t * the session.\n\t\t */\n\t\tgetAttendees(): ReadonlySet<Attendee>;\n\n\t\t/**\n\t\t * Lookup a specific {@link Attendee} in the session.\n\t\t *\n\t\t * @param clientId - Client connection or session ID\n\t\t */\n\t\tgetAttendee(clientId: ClientConnectionId | AttendeeId): Attendee;\n\n\t\t/**\n\t\t * Get this client's {@link Attendee}.\n\t\t *\n\t\t * @returns This client's attendee.\n\t\t */\n\t\tgetMyself(): Attendee;\n\t};\n\n\treadonly states: {\n\t\t/**\n\t\t * Acquires a StatesWorkspace from store or adds new one.\n\t\t *\n\t\t * @param workspaceAddress - Address of the requested StatesWorkspace\n\t\t * @param requestedStates - Requested states for the workspace\n\t\t * @param controls - Optional settings for default broadcast controls\n\t\t * @returns A StatesWorkspace\n\t\t */\n\t\tgetWorkspace<StatesSchema extends StatesWorkspaceSchema>(\n\t\t\tworkspaceAddress: WorkspaceAddress,\n\t\t\trequestedStates: StatesSchema,\n\t\t\tcontrols?: BroadcastControlSettings,\n\t\t): StatesWorkspace<StatesSchema>;\n\t};\n\n\treadonly notifications: {\n\t\t/**\n\t\t * Acquires a Notifications workspace from store or adds new one.\n\t\t *\n\t\t * @param workspaceAddress - Address of the requested Notifications Workspace\n\t\t * @param requestedNotifications - Requested notifications for the workspace\n\t\t * @returns A Notifications workspace\n\t\t */\n\t\tgetWorkspace<NotificationsSchema extends NotificationsWorkspaceSchema>(\n\t\t\tnotificationsId: WorkspaceAddress,\n\t\t\trequestedNotifications: NotificationsSchema,\n\t\t): NotificationsWorkspace<NotificationsSchema>;\n\t};\n}\n"]}
|
|
@@ -8,23 +8,23 @@ import type { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/intern
|
|
|
8
8
|
import type { ClientConnectionId } from "./baseTypes.js";
|
|
9
9
|
import type { BroadcastControlSettings } from "./broadcastControls.js";
|
|
10
10
|
import type { IEphemeralRuntime } from "./internalTypes.js";
|
|
11
|
-
import type {
|
|
11
|
+
import type { AttendeeId, Attendee, Presence, PresenceEvents } from "./presence.js";
|
|
12
12
|
import type { ClientUpdateEntry, PresenceStatesInternal } from "./presenceStates.js";
|
|
13
13
|
import type { SystemWorkspaceDatastore } from "./systemWorkspace.js";
|
|
14
|
-
import type {
|
|
14
|
+
import type { AnyWorkspace, NotificationsWorkspace, NotificationsWorkspaceSchema, StatesWorkspace, StatesWorkspaceSchema, WorkspaceAddress } from "./types.js";
|
|
15
15
|
import type { IExtensionMessage } from "@fluidframework/presence/internal/container-definitions/internal";
|
|
16
|
-
interface
|
|
17
|
-
public:
|
|
16
|
+
interface AnyWorkspaceEntry<TSchema extends StatesWorkspaceSchema> {
|
|
17
|
+
public: AnyWorkspace<TSchema>;
|
|
18
18
|
internal: PresenceStatesInternal;
|
|
19
19
|
}
|
|
20
20
|
interface SystemDatastore {
|
|
21
21
|
"system:presence": SystemWorkspaceDatastore;
|
|
22
22
|
}
|
|
23
|
-
type InternalWorkspaceAddress = `${"s" | "n"}:${
|
|
23
|
+
type InternalWorkspaceAddress = `${"s" | "n"}:${WorkspaceAddress}`;
|
|
24
24
|
interface GeneralDatastoreMessageContent {
|
|
25
25
|
[WorkspaceAddress: string]: {
|
|
26
26
|
[StateValueManagerKey: string]: {
|
|
27
|
-
[
|
|
27
|
+
[AttendeeId: AttendeeId]: ClientUpdateEntry;
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
30
|
}
|
|
@@ -54,27 +54,29 @@ interface ClientJoinMessage extends IInboundSignalMessage {
|
|
|
54
54
|
*/
|
|
55
55
|
export interface PresenceDatastoreManager {
|
|
56
56
|
joinSession(clientId: ClientConnectionId): void;
|
|
57
|
-
getWorkspace<TSchema extends
|
|
57
|
+
getWorkspace<TSchema extends StatesWorkspaceSchema>(internalWorkspaceAddress: `s:${WorkspaceAddress}`, requestedContent: TSchema, controls?: BroadcastControlSettings): StatesWorkspace<TSchema>;
|
|
58
|
+
getWorkspace<TSchema extends NotificationsWorkspaceSchema>(internalWorkspaceAddress: `n:${WorkspaceAddress}`, requestedContent: TSchema): NotificationsWorkspace<TSchema>;
|
|
58
59
|
processSignal(message: IExtensionMessage, local: boolean): void;
|
|
59
60
|
}
|
|
60
61
|
/**
|
|
61
62
|
* Manages singleton datastore for all Presence.
|
|
62
63
|
*/
|
|
63
64
|
export declare class PresenceDatastoreManagerImpl implements PresenceDatastoreManager {
|
|
64
|
-
private readonly
|
|
65
|
+
private readonly attendeeId;
|
|
65
66
|
private readonly runtime;
|
|
66
67
|
private readonly lookupClient;
|
|
67
68
|
private readonly logger;
|
|
68
69
|
private readonly events;
|
|
70
|
+
private readonly presence;
|
|
69
71
|
private readonly datastore;
|
|
70
72
|
private averageLatency;
|
|
71
73
|
private returnedMessages;
|
|
72
74
|
private refreshBroadcastRequested;
|
|
73
75
|
private readonly timer;
|
|
74
76
|
private readonly workspaces;
|
|
75
|
-
constructor(
|
|
77
|
+
constructor(attendeeId: AttendeeId, runtime: IEphemeralRuntime, lookupClient: (clientId: AttendeeId) => Attendee, logger: ITelemetryLoggerExt | undefined, events: IEmitter<PresenceEvents>, presence: Presence, systemWorkspaceDatastore: SystemWorkspaceDatastore, systemWorkspace: AnyWorkspaceEntry<StatesWorkspaceSchema>);
|
|
76
78
|
joinSession(clientId: ClientConnectionId): void;
|
|
77
|
-
getWorkspace<TSchema extends
|
|
79
|
+
getWorkspace<TSchema extends StatesWorkspaceSchema>(internalWorkspaceAddress: InternalWorkspaceAddress, requestedContent: TSchema, controls?: BroadcastControlSettings): AnyWorkspace<TSchema>;
|
|
78
80
|
/**
|
|
79
81
|
* The combined contents of all queued updates. Will be undefined when no messages are queued.
|
|
80
82
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presenceDatastoreManager.d.ts","sourceRoot":"","sources":["../src/presenceDatastoreManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AAEzE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAEpF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,EAAE,iBAAiB,EAAoB,MAAM,oBAAoB,CAAC;AAE9E,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"presenceDatastoreManager.d.ts","sourceRoot":"","sources":["../src/presenceDatastoreManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AAEzE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAEpF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,EAAE,iBAAiB,EAAoB,MAAM,oBAAoB,CAAC;AAE9E,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpF,OAAO,KAAK,EACX,iBAAiB,EAEjB,sBAAsB,EAEtB,MAAM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EAAE,mBAAmB,GAAG,SAAS,EACvC,MAAM,EAAE,QAAQ,CAAC,cAAc,CAAC,EAChC,QAAQ,EAAE,QAAQ,EACnC,wBAAwB,EAAE,wBAAwB,EAClD,eAAe,EAAE,iBAAiB,CAAC,qBAAqB,CAAC;IAOnD,WAAW,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAkB/C,YAAY,CAAC,OAAO,SAAS,qBAAqB,EACxD,wBAAwB,EAAE,wBAAwB,EAClD,gBAAgB,EAAE,OAAO,EACzB,QAAQ,CAAC,EAAE,wBAAwB,GACjC,YAAY,CAAC,OAAO,CAAC;IAkDxB;;OAEG;IACH,OAAO,CAAC,UAAU,CAA6C;IAE/D;;;OAGG;IACH,OAAO,CAAC,cAAc;IAuCtB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA2CzB,OAAO,CAAC,sBAAsB;IAUvB,aAAa,CAOnB,OAAO,EAAE,qBAAqB,GAAG,sBAAsB,GAAG,iBAAiB,EAC3E,KAAK,EAAE,OAAO,GACZ,IAAI;IA+FP;;;;;;;;;;OAUG;IACH,OAAO,CAAC,mBAAmB;CAgE3B"}
|
|
@@ -30,10 +30,10 @@ function mergeGeneralDatastoreMessageContent(base, newData) {
|
|
|
30
30
|
const mergedData = queueDatastore[workspaceName] ?? {};
|
|
31
31
|
// Iterate over each value manager and its data, merging it as needed.
|
|
32
32
|
for (const [valueManagerKey, valueManagerValue] of (0, internalUtils_js_1.objectEntries)(workspaceData)) {
|
|
33
|
-
for (const [
|
|
33
|
+
for (const [attendeeId, value] of (0, internalUtils_js_1.objectEntries)(valueManagerValue)) {
|
|
34
34
|
const mergeObject = (mergedData[valueManagerKey] ??= {});
|
|
35
|
-
const oldData = mergeObject[
|
|
36
|
-
mergeObject[
|
|
35
|
+
const oldData = mergeObject[attendeeId];
|
|
36
|
+
mergeObject[attendeeId] = (0, presenceStates_js_1.mergeValueDirectory)(oldData, value, 0);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
// Store the merged data in the function-local queue workspace. The whole contents of this
|
|
@@ -46,12 +46,13 @@ function mergeGeneralDatastoreMessageContent(base, newData) {
|
|
|
46
46
|
* Manages singleton datastore for all Presence.
|
|
47
47
|
*/
|
|
48
48
|
class PresenceDatastoreManagerImpl {
|
|
49
|
-
constructor(
|
|
50
|
-
this.
|
|
49
|
+
constructor(attendeeId, runtime, lookupClient, logger, events, presence, systemWorkspaceDatastore, systemWorkspace) {
|
|
50
|
+
this.attendeeId = attendeeId;
|
|
51
51
|
this.runtime = runtime;
|
|
52
52
|
this.lookupClient = lookupClient;
|
|
53
53
|
this.logger = logger;
|
|
54
54
|
this.events = events;
|
|
55
|
+
this.presence = presence;
|
|
55
56
|
this.averageLatency = 0;
|
|
56
57
|
this.returnedMessages = 0;
|
|
57
58
|
this.refreshBroadcastRequested = false;
|
|
@@ -92,14 +93,15 @@ class PresenceDatastoreManagerImpl {
|
|
|
92
93
|
}
|
|
93
94
|
const updates = {};
|
|
94
95
|
for (const [key, value] of Object.entries(states)) {
|
|
95
|
-
updates[key] = { [this.
|
|
96
|
+
updates[key] = { [this.attendeeId]: value };
|
|
96
97
|
}
|
|
97
98
|
this.enqueueMessage({
|
|
98
99
|
[internalWorkspaceAddress]: updates,
|
|
99
100
|
}, options);
|
|
100
101
|
};
|
|
101
102
|
const entry = (0, presenceStates_js_1.createPresenceStates)({
|
|
102
|
-
|
|
103
|
+
presence: this.presence,
|
|
104
|
+
attendeeId: this.attendeeId,
|
|
103
105
|
lookupClient: this.lookupClient,
|
|
104
106
|
localUpdate,
|
|
105
107
|
}, workspaceDatastore, requestedContent, controls);
|
|
@@ -193,7 +195,7 @@ class PresenceDatastoreManagerImpl {
|
|
|
193
195
|
processSignal(
|
|
194
196
|
// Note: IInboundSignalMessage is used here in place of IExtensionMessage
|
|
195
197
|
// as IExtensionMessage's strictly JSON `content` creates type compatibility
|
|
196
|
-
// issues with `
|
|
198
|
+
// issues with `AttendeeId` keys and really unknown value content.
|
|
197
199
|
// IExtensionMessage is a subset of IInboundSignalMessage so this is safe.
|
|
198
200
|
// Change types of DatastoreUpdateMessage | ClientJoinMessage to
|
|
199
201
|
// IExtensionMessage<> derivatives to see the issues.
|