@matter/protocol 0.16.0-alpha.0-20251213-e83db3732 → 0.16.0-alpha.0-20251217-038f88085
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/LICENSE +1 -1
- package/dist/cjs/action/client/ClientInteraction.d.ts +12 -5
- package/dist/cjs/action/client/ClientInteraction.d.ts.map +1 -1
- package/dist/cjs/action/client/ClientInteraction.js +39 -15
- package/dist/cjs/action/client/ClientInteraction.js.map +1 -1
- package/dist/cjs/action/client/ClientRead.d.ts +10 -0
- package/dist/cjs/action/client/ClientRead.d.ts.map +1 -0
- package/dist/cjs/action/client/ClientRead.js +22 -0
- package/dist/cjs/action/client/ClientRead.js.map +6 -0
- package/dist/cjs/action/client/ClientRequest.d.ts +20 -0
- package/dist/cjs/action/client/ClientRequest.d.ts.map +1 -0
- package/dist/cjs/action/client/ClientRequest.js +22 -0
- package/dist/cjs/action/client/ClientRequest.js.map +6 -0
- package/dist/cjs/action/client/ClientWrite.d.ts +10 -0
- package/dist/cjs/action/client/ClientWrite.d.ts.map +1 -0
- package/dist/cjs/action/client/ClientWrite.js +22 -0
- package/dist/cjs/action/client/ClientWrite.js.map +6 -0
- package/dist/cjs/action/client/QueuedClientInteraction.d.ts +49 -0
- package/dist/cjs/action/client/QueuedClientInteraction.d.ts.map +1 -0
- package/dist/cjs/action/client/QueuedClientInteraction.js +160 -0
- package/dist/cjs/action/client/QueuedClientInteraction.js.map +6 -0
- package/dist/cjs/action/client/index.d.ts +4 -0
- package/dist/cjs/action/client/index.d.ts.map +1 -1
- package/dist/cjs/action/client/index.js +4 -0
- package/dist/cjs/action/client/index.js.map +1 -1
- package/dist/cjs/action/client/subscription/ClientSubscribe.d.ts +2 -1
- package/dist/cjs/action/client/subscription/ClientSubscribe.d.ts.map +1 -1
- package/dist/cjs/action/client/subscription/ClientSubscriptionHandler.d.ts.map +1 -1
- package/dist/cjs/action/client/subscription/ClientSubscriptionHandler.js +14 -3
- package/dist/cjs/action/client/subscription/ClientSubscriptionHandler.js.map +1 -1
- package/dist/cjs/action/client/subscription/SustainedSubscription.d.ts +1 -1
- package/dist/cjs/action/client/subscription/SustainedSubscription.d.ts.map +1 -1
- package/dist/cjs/action/client/subscription/SustainedSubscription.js +1 -4
- package/dist/cjs/action/client/subscription/SustainedSubscription.js.map +1 -1
- package/dist/cjs/action/request/Invoke.d.ts +7 -1
- package/dist/cjs/action/request/Invoke.d.ts.map +1 -1
- package/dist/cjs/action/request/Invoke.js +0 -3
- package/dist/cjs/action/request/Invoke.js.map +1 -1
- package/dist/cjs/action/request/Read.d.ts.map +1 -1
- package/dist/cjs/action/request/Read.js +3 -2
- package/dist/cjs/action/request/Read.js.map +1 -1
- package/dist/cjs/action/request/Specifier.d.ts +1 -1
- package/dist/cjs/action/request/Specifier.d.ts.map +1 -1
- package/dist/cjs/action/request/Specifier.js +3 -0
- package/dist/cjs/action/request/Specifier.js.map +1 -1
- package/dist/cjs/action/request/Write.d.ts +1 -0
- package/dist/cjs/action/request/Write.d.ts.map +1 -1
- package/dist/cjs/action/request/Write.js +10 -2
- package/dist/cjs/action/request/Write.js.map +1 -1
- package/dist/cjs/action/response/ReadResult.d.ts +1 -1
- package/dist/cjs/action/response/ReadResult.d.ts.map +1 -1
- package/dist/cjs/cluster/client/ClusterClientTypes.d.ts +37 -8
- package/dist/cjs/cluster/client/ClusterClientTypes.d.ts.map +1 -1
- package/dist/cjs/cluster/client/index.d.ts +0 -3
- package/dist/cjs/cluster/client/index.d.ts.map +1 -1
- package/dist/cjs/cluster/client/index.js +0 -3
- package/dist/cjs/cluster/client/index.js.map +1 -1
- package/dist/cjs/interaction/InteractionMessenger.d.ts.map +1 -1
- package/dist/cjs/interaction/InteractionMessenger.js +3 -2
- package/dist/cjs/interaction/InteractionMessenger.js.map +1 -1
- package/dist/cjs/interaction/SubscriptionClient.d.ts.map +1 -1
- package/dist/cjs/interaction/SubscriptionClient.js +2 -1
- package/dist/cjs/interaction/SubscriptionClient.js.map +1 -1
- package/dist/cjs/interaction/index.d.ts +1 -1
- package/dist/cjs/interaction/index.d.ts.map +1 -1
- package/dist/cjs/interaction/index.js +1 -1
- package/dist/cjs/interaction/index.js.map +1 -1
- package/dist/cjs/peer/CommissioningError.d.ts +13 -0
- package/dist/cjs/peer/CommissioningError.d.ts.map +1 -0
- package/dist/cjs/peer/CommissioningError.js +32 -0
- package/dist/cjs/peer/CommissioningError.js.map +6 -0
- package/dist/cjs/peer/ControllerCommissioner.d.ts +2 -3
- package/dist/cjs/peer/ControllerCommissioner.d.ts.map +1 -1
- package/dist/cjs/peer/ControllerCommissioner.js +20 -13
- package/dist/cjs/peer/ControllerCommissioner.js.map +2 -2
- package/dist/cjs/peer/ControllerCommissioningFlow.d.ts +7 -16
- package/dist/cjs/peer/ControllerCommissioningFlow.d.ts.map +1 -1
- package/dist/cjs/peer/ControllerCommissioningFlow.js +395 -178
- package/dist/cjs/peer/ControllerCommissioningFlow.js.map +1 -1
- package/dist/cjs/peer/ControllerDiscovery.d.ts +4 -0
- package/dist/cjs/peer/ControllerDiscovery.d.ts.map +1 -1
- package/dist/cjs/peer/ControllerDiscovery.js +6 -3
- package/dist/cjs/peer/ControllerDiscovery.js.map +1 -1
- package/dist/cjs/peer/InteractionQueue.d.ts +2 -2
- package/dist/cjs/peer/InteractionQueue.d.ts.map +1 -1
- package/dist/cjs/peer/InteractionQueue.js +1 -1
- package/dist/cjs/peer/InteractionQueue.js.map +1 -1
- package/dist/cjs/peer/PeerAddressStore.d.ts +0 -9
- package/dist/cjs/peer/PeerAddressStore.d.ts.map +1 -1
- package/dist/cjs/peer/PeerAddressStore.js.map +1 -1
- package/dist/cjs/peer/PeerSet.d.ts +0 -2
- package/dist/cjs/peer/PeerSet.d.ts.map +1 -1
- package/dist/cjs/peer/PeerSet.js +32 -18
- package/dist/cjs/peer/PeerSet.js.map +1 -1
- package/dist/cjs/peer/PhysicalDeviceProperties.js +1 -1
- package/dist/cjs/peer/PhysicalDeviceProperties.js.map +1 -1
- package/dist/cjs/peer/index.d.ts +1 -0
- package/dist/cjs/peer/index.d.ts.map +1 -1
- package/dist/cjs/peer/index.js +1 -0
- package/dist/cjs/peer/index.js.map +1 -1
- package/dist/cjs/protocol/DeviceCommissioner.d.ts.map +1 -1
- package/dist/cjs/protocol/DeviceCommissioner.js.map +1 -1
- package/dist/cjs/protocol/ExchangeManager.js +2 -2
- package/dist/cjs/protocol/ExchangeManager.js.map +1 -1
- package/dist/cjs/protocol/ExchangeProvider.d.ts +13 -4
- package/dist/cjs/protocol/ExchangeProvider.d.ts.map +1 -1
- package/dist/cjs/protocol/ExchangeProvider.js +5 -3
- package/dist/cjs/protocol/ExchangeProvider.js.map +1 -1
- package/dist/cjs/session/NodeSession.d.ts +5 -2
- package/dist/cjs/session/NodeSession.d.ts.map +1 -1
- package/dist/cjs/session/NodeSession.js +5 -4
- package/dist/cjs/session/NodeSession.js.map +1 -1
- package/dist/cjs/session/Session.d.ts +5 -3
- package/dist/cjs/session/Session.d.ts.map +1 -1
- package/dist/cjs/session/Session.js +8 -4
- package/dist/cjs/session/Session.js.map +1 -1
- package/dist/cjs/session/SessionManager.d.ts +8 -0
- package/dist/cjs/session/SessionManager.d.ts.map +1 -1
- package/dist/cjs/session/SessionManager.js +16 -2
- package/dist/cjs/session/SessionManager.js.map +1 -1
- package/dist/esm/action/client/ClientInteraction.d.ts +12 -5
- package/dist/esm/action/client/ClientInteraction.d.ts.map +1 -1
- package/dist/esm/action/client/ClientInteraction.js +42 -16
- package/dist/esm/action/client/ClientInteraction.js.map +1 -1
- package/dist/esm/action/client/ClientRead.d.ts +10 -0
- package/dist/esm/action/client/ClientRead.d.ts.map +1 -0
- package/dist/esm/action/client/ClientRead.js +6 -0
- package/dist/esm/action/client/ClientRead.js.map +6 -0
- package/dist/esm/action/client/ClientRequest.d.ts +20 -0
- package/dist/esm/action/client/ClientRequest.d.ts.map +1 -0
- package/dist/esm/action/client/ClientRequest.js +6 -0
- package/dist/esm/action/client/ClientRequest.js.map +6 -0
- package/dist/esm/action/client/ClientWrite.d.ts +10 -0
- package/dist/esm/action/client/ClientWrite.d.ts.map +1 -0
- package/dist/esm/action/client/ClientWrite.js +6 -0
- package/dist/esm/action/client/ClientWrite.js.map +6 -0
- package/dist/esm/action/client/QueuedClientInteraction.d.ts +49 -0
- package/dist/esm/action/client/QueuedClientInteraction.d.ts.map +1 -0
- package/dist/esm/action/client/QueuedClientInteraction.js +140 -0
- package/dist/esm/action/client/QueuedClientInteraction.js.map +6 -0
- package/dist/esm/action/client/index.d.ts +4 -0
- package/dist/esm/action/client/index.d.ts.map +1 -1
- package/dist/esm/action/client/index.js +4 -0
- package/dist/esm/action/client/index.js.map +1 -1
- package/dist/esm/action/client/subscription/ClientSubscribe.d.ts +2 -1
- package/dist/esm/action/client/subscription/ClientSubscribe.d.ts.map +1 -1
- package/dist/esm/action/client/subscription/ClientSubscriptionHandler.d.ts.map +1 -1
- package/dist/esm/action/client/subscription/ClientSubscriptionHandler.js +14 -3
- package/dist/esm/action/client/subscription/ClientSubscriptionHandler.js.map +1 -1
- package/dist/esm/action/client/subscription/SustainedSubscription.d.ts +1 -1
- package/dist/esm/action/client/subscription/SustainedSubscription.d.ts.map +1 -1
- package/dist/esm/action/client/subscription/SustainedSubscription.js +1 -4
- package/dist/esm/action/client/subscription/SustainedSubscription.js.map +1 -1
- package/dist/esm/action/request/Invoke.d.ts +7 -1
- package/dist/esm/action/request/Invoke.d.ts.map +1 -1
- package/dist/esm/action/request/Invoke.js +0 -3
- package/dist/esm/action/request/Invoke.js.map +1 -1
- package/dist/esm/action/request/Read.d.ts.map +1 -1
- package/dist/esm/action/request/Read.js +3 -2
- package/dist/esm/action/request/Read.js.map +1 -1
- package/dist/esm/action/request/Specifier.d.ts +1 -1
- package/dist/esm/action/request/Specifier.d.ts.map +1 -1
- package/dist/esm/action/request/Specifier.js +3 -0
- package/dist/esm/action/request/Specifier.js.map +1 -1
- package/dist/esm/action/request/Write.d.ts +1 -0
- package/dist/esm/action/request/Write.d.ts.map +1 -1
- package/dist/esm/action/request/Write.js +10 -2
- package/dist/esm/action/request/Write.js.map +1 -1
- package/dist/esm/action/response/ReadResult.d.ts +1 -1
- package/dist/esm/action/response/ReadResult.d.ts.map +1 -1
- package/dist/esm/cluster/client/ClusterClientTypes.d.ts +37 -8
- package/dist/esm/cluster/client/ClusterClientTypes.d.ts.map +1 -1
- package/dist/esm/cluster/client/index.d.ts +0 -3
- package/dist/esm/cluster/client/index.d.ts.map +1 -1
- package/dist/esm/cluster/client/index.js +0 -3
- package/dist/esm/cluster/client/index.js.map +1 -1
- package/dist/esm/interaction/InteractionMessenger.d.ts.map +1 -1
- package/dist/esm/interaction/InteractionMessenger.js +4 -3
- package/dist/esm/interaction/InteractionMessenger.js.map +1 -1
- package/dist/esm/interaction/SubscriptionClient.d.ts.map +1 -1
- package/dist/esm/interaction/SubscriptionClient.js +2 -1
- package/dist/esm/interaction/SubscriptionClient.js.map +1 -1
- package/dist/esm/interaction/index.d.ts +1 -1
- package/dist/esm/interaction/index.d.ts.map +1 -1
- package/dist/esm/interaction/index.js +1 -1
- package/dist/esm/peer/CommissioningError.d.ts +13 -0
- package/dist/esm/peer/CommissioningError.d.ts.map +1 -0
- package/dist/esm/peer/CommissioningError.js +12 -0
- package/dist/esm/peer/CommissioningError.js.map +6 -0
- package/dist/esm/peer/ControllerCommissioner.d.ts +2 -3
- package/dist/esm/peer/ControllerCommissioner.d.ts.map +1 -1
- package/dist/esm/peer/ControllerCommissioner.js +19 -13
- package/dist/esm/peer/ControllerCommissioner.js.map +2 -2
- package/dist/esm/peer/ControllerCommissioningFlow.d.ts +7 -16
- package/dist/esm/peer/ControllerCommissioningFlow.d.ts.map +1 -1
- package/dist/esm/peer/ControllerCommissioningFlow.js +380 -162
- package/dist/esm/peer/ControllerCommissioningFlow.js.map +1 -1
- package/dist/esm/peer/ControllerDiscovery.d.ts +4 -0
- package/dist/esm/peer/ControllerDiscovery.d.ts.map +1 -1
- package/dist/esm/peer/ControllerDiscovery.js +4 -1
- package/dist/esm/peer/ControllerDiscovery.js.map +1 -1
- package/dist/esm/peer/InteractionQueue.d.ts +2 -2
- package/dist/esm/peer/InteractionQueue.d.ts.map +1 -1
- package/dist/esm/peer/InteractionQueue.js +2 -2
- package/dist/esm/peer/InteractionQueue.js.map +1 -1
- package/dist/esm/peer/PeerAddressStore.d.ts +0 -9
- package/dist/esm/peer/PeerAddressStore.d.ts.map +1 -1
- package/dist/esm/peer/PeerAddressStore.js.map +1 -1
- package/dist/esm/peer/PeerSet.d.ts +0 -2
- package/dist/esm/peer/PeerSet.d.ts.map +1 -1
- package/dist/esm/peer/PeerSet.js +32 -18
- package/dist/esm/peer/PeerSet.js.map +1 -1
- package/dist/esm/peer/PhysicalDeviceProperties.js +1 -1
- package/dist/esm/peer/PhysicalDeviceProperties.js.map +1 -1
- package/dist/esm/peer/index.d.ts +1 -0
- package/dist/esm/peer/index.d.ts.map +1 -1
- package/dist/esm/peer/index.js +1 -0
- package/dist/esm/peer/index.js.map +1 -1
- package/dist/esm/protocol/DeviceCommissioner.d.ts.map +1 -1
- package/dist/esm/protocol/DeviceCommissioner.js.map +1 -1
- package/dist/esm/protocol/ExchangeManager.js +2 -2
- package/dist/esm/protocol/ExchangeManager.js.map +1 -1
- package/dist/esm/protocol/ExchangeProvider.d.ts +13 -4
- package/dist/esm/protocol/ExchangeProvider.d.ts.map +1 -1
- package/dist/esm/protocol/ExchangeProvider.js +5 -3
- package/dist/esm/protocol/ExchangeProvider.js.map +1 -1
- package/dist/esm/session/NodeSession.d.ts +5 -2
- package/dist/esm/session/NodeSession.d.ts.map +1 -1
- package/dist/esm/session/NodeSession.js +5 -4
- package/dist/esm/session/NodeSession.js.map +1 -1
- package/dist/esm/session/Session.d.ts +5 -3
- package/dist/esm/session/Session.d.ts.map +1 -1
- package/dist/esm/session/Session.js +8 -4
- package/dist/esm/session/Session.js.map +1 -1
- package/dist/esm/session/SessionManager.d.ts +8 -0
- package/dist/esm/session/SessionManager.d.ts.map +1 -1
- package/dist/esm/session/SessionManager.js +17 -2
- package/dist/esm/session/SessionManager.js.map +1 -1
- package/package.json +6 -6
- package/src/action/client/ClientInteraction.ts +58 -19
- package/src/action/client/ClientRead.ts +10 -0
- package/src/action/client/ClientRequest.ts +20 -0
- package/src/action/client/ClientWrite.ts +10 -0
- package/src/action/client/QueuedClientInteraction.ts +91 -0
- package/src/action/client/index.ts +4 -0
- package/src/action/client/subscription/ClientSubscribe.ts +2 -1
- package/src/action/client/subscription/ClientSubscriptionHandler.ts +14 -3
- package/src/action/client/subscription/SustainedSubscription.ts +6 -9
- package/src/action/request/Invoke.ts +11 -4
- package/src/action/request/Read.ts +3 -2
- package/src/action/request/Specifier.ts +4 -1
- package/src/action/request/Write.ts +11 -2
- package/src/action/response/ReadResult.ts +1 -1
- package/src/cluster/client/ClusterClientTypes.ts +47 -7
- package/src/cluster/client/index.ts +0 -3
- package/src/interaction/InteractionMessenger.ts +5 -4
- package/src/interaction/SubscriptionClient.ts +2 -1
- package/src/interaction/index.ts +1 -1
- package/src/peer/CommissioningError.ts +13 -0
- package/src/peer/ControllerCommissioner.ts +21 -13
- package/src/peer/ControllerCommissioningFlow.ts +418 -186
- package/src/peer/ControllerDiscovery.ts +4 -1
- package/src/peer/InteractionQueue.ts +2 -2
- package/src/peer/PeerAddressStore.ts +0 -9
- package/src/peer/PeerSet.ts +56 -23
- package/src/peer/PhysicalDeviceProperties.ts +1 -1
- package/src/peer/index.ts +1 -0
- package/src/protocol/DeviceCommissioner.ts +0 -1
- package/src/protocol/ExchangeManager.ts +2 -2
- package/src/protocol/ExchangeProvider.ts +9 -7
- package/src/session/NodeSession.ts +5 -4
- package/src/session/Session.ts +8 -4
- package/src/session/SessionManager.ts +19 -2
- package/dist/cjs/cluster/client/AttributeClient.d.ts +0 -75
- package/dist/cjs/cluster/client/AttributeClient.d.ts.map +0 -1
- package/dist/cjs/cluster/client/AttributeClient.js +0 -209
- package/dist/cjs/cluster/client/AttributeClient.js.map +0 -6
- package/dist/cjs/cluster/client/ClusterClient.d.ts +0 -11
- package/dist/cjs/cluster/client/ClusterClient.d.ts.map +0 -1
- package/dist/cjs/cluster/client/ClusterClient.js +0 -335
- package/dist/cjs/cluster/client/ClusterClient.js.map +0 -6
- package/dist/cjs/cluster/client/EventClient.d.ts +0 -33
- package/dist/cjs/cluster/client/EventClient.d.ts.map +0 -1
- package/dist/cjs/cluster/client/EventClient.js +0 -89
- package/dist/cjs/cluster/client/EventClient.js.map +0 -6
- package/dist/cjs/interaction/InteractionClient.d.ts +0 -375
- package/dist/cjs/interaction/InteractionClient.d.ts.map +0 -1
- package/dist/cjs/interaction/InteractionClient.js +0 -1046
- package/dist/cjs/interaction/InteractionClient.js.map +0 -6
- package/dist/esm/cluster/client/AttributeClient.d.ts +0 -75
- package/dist/esm/cluster/client/AttributeClient.d.ts.map +0 -1
- package/dist/esm/cluster/client/AttributeClient.js +0 -189
- package/dist/esm/cluster/client/AttributeClient.js.map +0 -6
- package/dist/esm/cluster/client/ClusterClient.d.ts +0 -11
- package/dist/esm/cluster/client/ClusterClient.d.ts.map +0 -1
- package/dist/esm/cluster/client/ClusterClient.js +0 -320
- package/dist/esm/cluster/client/ClusterClient.js.map +0 -6
- package/dist/esm/cluster/client/EventClient.d.ts +0 -33
- package/dist/esm/cluster/client/EventClient.d.ts.map +0 -1
- package/dist/esm/cluster/client/EventClient.js +0 -69
- package/dist/esm/cluster/client/EventClient.js.map +0 -6
- package/dist/esm/interaction/InteractionClient.d.ts +0 -375
- package/dist/esm/interaction/InteractionClient.d.ts.map +0 -1
- package/dist/esm/interaction/InteractionClient.js +0 -1047
- package/dist/esm/interaction/InteractionClient.js.map +0 -6
- package/src/cluster/client/AttributeClient.ts +0 -230
- package/src/cluster/client/ClusterClient.ts +0 -433
- package/src/cluster/client/EventClient.ts +0 -99
- package/src/interaction/InteractionClient.ts +0 -1614
|
@@ -1,433 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { capitalize, Diagnostic, Duration, ImplementationError, Logger, Merge } from "#general";
|
|
8
|
-
import {
|
|
9
|
-
Attribute,
|
|
10
|
-
AttributeId,
|
|
11
|
-
ClusterId,
|
|
12
|
-
ClusterType,
|
|
13
|
-
Command,
|
|
14
|
-
CommandId,
|
|
15
|
-
EndpointNumber,
|
|
16
|
-
Event,
|
|
17
|
-
EventId,
|
|
18
|
-
GlobalAttributes,
|
|
19
|
-
StatusCode,
|
|
20
|
-
StatusResponseError,
|
|
21
|
-
TlvEventFilter,
|
|
22
|
-
TypeFromPartialBitSchema,
|
|
23
|
-
TypeFromSchema,
|
|
24
|
-
UnknownAttribute,
|
|
25
|
-
} from "#types";
|
|
26
|
-
import { DecodedEventData } from "../../interaction/EventDataDecoder.js";
|
|
27
|
-
import { InteractionClient } from "../../interaction/InteractionClient.js";
|
|
28
|
-
import { createAttributeClient } from "./AttributeClient.js";
|
|
29
|
-
import {
|
|
30
|
-
AttributeClients,
|
|
31
|
-
AttributeClientValues,
|
|
32
|
-
ClusterClientObj,
|
|
33
|
-
EventClients,
|
|
34
|
-
GroupClusterClientObj,
|
|
35
|
-
SignatureFromCommandSpec,
|
|
36
|
-
SignatureFromCommandSpecWithoutResponse,
|
|
37
|
-
} from "./ClusterClientTypes.js";
|
|
38
|
-
import { createEventClient } from "./EventClient.js";
|
|
39
|
-
|
|
40
|
-
const logger = Logger.get("ClusterClient");
|
|
41
|
-
|
|
42
|
-
export function GroupClusterClient<const T extends ClusterType>(
|
|
43
|
-
clusterDef: T,
|
|
44
|
-
interactionClient: InteractionClient,
|
|
45
|
-
globalAttributeValues: Partial<AttributeClientValues<GlobalAttributes<T["features"]>>> = {},
|
|
46
|
-
): GroupClusterClientObj<T> {
|
|
47
|
-
if (!interactionClient.isGroupAddress) {
|
|
48
|
-
throw new Error("GroupClusterClient must be used with a GroupAddress InteractionClient");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return ClusterClient(clusterDef, undefined, interactionClient, globalAttributeValues);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export function ClusterClient<const T extends ClusterType>(
|
|
55
|
-
clusterDef: T,
|
|
56
|
-
endpointId: EndpointNumber | undefined,
|
|
57
|
-
interactionClient: InteractionClient,
|
|
58
|
-
globalAttributeValues: Partial<AttributeClientValues<GlobalAttributes<T["features"]>>> = {},
|
|
59
|
-
): ClusterClientObj<T> {
|
|
60
|
-
const isGroupAddress = interactionClient.isGroupAddress;
|
|
61
|
-
if (isGroupAddress !== (endpointId === undefined)) {
|
|
62
|
-
throw new Error("Endpoint ID must be defined for a Non-Group ClusterClient");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function addAttributeToResult(attribute: Attribute<any, any>, attributeName: string) {
|
|
66
|
-
(attributes as any)[attributeName] = createAttributeClient(
|
|
67
|
-
attribute,
|
|
68
|
-
attributeName,
|
|
69
|
-
endpointId,
|
|
70
|
-
clusterId,
|
|
71
|
-
interactionClient,
|
|
72
|
-
!!globalAttributeValues?.attributeList?.includes(attribute.id),
|
|
73
|
-
);
|
|
74
|
-
(attributes as any)[attribute.id] = (attributes as any)[attributeName];
|
|
75
|
-
attributeToId[attribute.id] = attributeName;
|
|
76
|
-
const capitalizedAttributeName = capitalize(attributeName);
|
|
77
|
-
result[`get${capitalizedAttributeName}Attribute`] = async (
|
|
78
|
-
requestFromRemote?: boolean,
|
|
79
|
-
isFabricFiltered = true,
|
|
80
|
-
) => {
|
|
81
|
-
if (isGroupAddress) {
|
|
82
|
-
throw new ImplementationError("Group cluster clients do not support reading attributes");
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
try {
|
|
86
|
-
return await (attributes as any)[attributeName].get(requestFromRemote, isFabricFiltered);
|
|
87
|
-
} catch (e) {
|
|
88
|
-
if (StatusResponseError.is(e, StatusCode.UnsupportedAttribute)) {
|
|
89
|
-
return undefined;
|
|
90
|
-
}
|
|
91
|
-
throw e;
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
result[`get${capitalizedAttributeName}AttributeFromCache`] = () => {
|
|
95
|
-
if (isGroupAddress) {
|
|
96
|
-
throw new ImplementationError("Group cluster clients do not support reading attributes");
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return (attributes as any)[attributeName].getLocal();
|
|
100
|
-
};
|
|
101
|
-
result[`set${capitalizedAttributeName}Attribute`] = async <T>(value: T, dataVersion?: number) =>
|
|
102
|
-
(attributes as any)[attributeName].set(value, dataVersion);
|
|
103
|
-
result[`subscribe${capitalizedAttributeName}Attribute`] = async <T>(
|
|
104
|
-
listener: (value: T) => void,
|
|
105
|
-
minIntervalS: number,
|
|
106
|
-
maxIntervalS: number,
|
|
107
|
-
knownDataVersion?: number,
|
|
108
|
-
isFabricFiltered?: boolean,
|
|
109
|
-
) => {
|
|
110
|
-
if (isGroupAddress) {
|
|
111
|
-
throw new ImplementationError("Group cluster clients do not support subscribing attributes");
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
(attributes as any)[attributeName].addListener(listener);
|
|
115
|
-
return (attributes as any)[attributeName].subscribe(
|
|
116
|
-
minIntervalS,
|
|
117
|
-
maxIntervalS,
|
|
118
|
-
knownDataVersion,
|
|
119
|
-
isFabricFiltered,
|
|
120
|
-
);
|
|
121
|
-
};
|
|
122
|
-
result[`add${capitalizedAttributeName}AttributeListener`] = <T>(listener: (value: T) => void) => {
|
|
123
|
-
if (isGroupAddress) {
|
|
124
|
-
throw new ImplementationError("Group cluster clients do not support subscribing attributes");
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
(attributes as any)[attributeName].addListener(listener);
|
|
128
|
-
};
|
|
129
|
-
result[`remove${capitalizedAttributeName}AttributeListener`] = <T>(listener: (value: T) => void) => {
|
|
130
|
-
if (isGroupAddress) {
|
|
131
|
-
throw new ImplementationError("Group cluster clients do not support subscribing attributes");
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
(attributes as any)[attributeName].removeListener(listener);
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function addEventToResult(event: Event<any, any>, eventName: string) {
|
|
139
|
-
(events as any)[eventName] = createEventClient(event, eventName, endpointId, clusterId, interactionClient);
|
|
140
|
-
(events as any)[event.id] = (events as any)[eventName];
|
|
141
|
-
eventToId[event.id] = eventName;
|
|
142
|
-
const capitalizedEventName = capitalize(eventName);
|
|
143
|
-
result[`get${capitalizedEventName}Event`] = async (
|
|
144
|
-
minimumEventNumber?: number | bigint,
|
|
145
|
-
isFabricFiltered?: boolean,
|
|
146
|
-
) => {
|
|
147
|
-
if (isGroupAddress) {
|
|
148
|
-
throw new ImplementationError("Group cluster clients do not support reading events");
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
try {
|
|
152
|
-
return await (events as any)[eventName].get(minimumEventNumber, isFabricFiltered);
|
|
153
|
-
} catch (e) {
|
|
154
|
-
if (StatusResponseError.is(e, StatusCode.UnsupportedEvent)) {
|
|
155
|
-
return undefined;
|
|
156
|
-
}
|
|
157
|
-
throw e;
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
result[`subscribe${capitalizedEventName}Event`] = async <T>(
|
|
161
|
-
listener: (value: DecodedEventData<T>) => void,
|
|
162
|
-
minIntervalS: number,
|
|
163
|
-
maxIntervalS: number,
|
|
164
|
-
isUrgent?: boolean,
|
|
165
|
-
minimumEventNumber?: number | bigint,
|
|
166
|
-
isFabricFiltered?: boolean,
|
|
167
|
-
) => {
|
|
168
|
-
if (isGroupAddress) {
|
|
169
|
-
throw new ImplementationError("Group cluster clients do not support subscribing to events");
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
(events as any)[eventName].addListener(listener);
|
|
173
|
-
return (events as any)[eventName].subscribe(
|
|
174
|
-
minIntervalS,
|
|
175
|
-
maxIntervalS,
|
|
176
|
-
isUrgent,
|
|
177
|
-
minimumEventNumber,
|
|
178
|
-
isFabricFiltered,
|
|
179
|
-
);
|
|
180
|
-
};
|
|
181
|
-
result[`add${capitalizedEventName}EventListener`] = <T>(listener: (value: DecodedEventData<T>) => void) => {
|
|
182
|
-
if (isGroupAddress) {
|
|
183
|
-
throw new ImplementationError("Group cluster clients do not support subscribing events");
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
(events as any)[eventName].addListener(listener);
|
|
187
|
-
};
|
|
188
|
-
result[`remove${capitalizedEventName}EventListener`] = <T>(listener: (value: DecodedEventData<T>) => void) => {
|
|
189
|
-
if (isGroupAddress) {
|
|
190
|
-
throw new ImplementationError("Group cluster clients do not support subscribing events");
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
(events as any)[eventName].removeListener(listener);
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const {
|
|
198
|
-
id: clusterId,
|
|
199
|
-
name,
|
|
200
|
-
commands: commandDef,
|
|
201
|
-
attributes: attributeDef,
|
|
202
|
-
events: eventDef,
|
|
203
|
-
features,
|
|
204
|
-
supportedFeatures,
|
|
205
|
-
revision,
|
|
206
|
-
unknown,
|
|
207
|
-
} = clusterDef;
|
|
208
|
-
const attributes = <AttributeClients<T["features"], T["attributes"]>>{};
|
|
209
|
-
const events = <EventClients<T["events"]>>{};
|
|
210
|
-
const commands = <
|
|
211
|
-
{
|
|
212
|
-
[P in keyof T["commands"]]:
|
|
213
|
-
| SignatureFromCommandSpec<T["commands"][P]>
|
|
214
|
-
| SignatureFromCommandSpecWithoutResponse<T["commands"][P]>;
|
|
215
|
-
}
|
|
216
|
-
>{};
|
|
217
|
-
|
|
218
|
-
let reportedFeatures: TypeFromPartialBitSchema<T["features"]> | undefined = undefined;
|
|
219
|
-
// If we have global attribute values we use them to modify
|
|
220
|
-
if (globalAttributeValues !== undefined) {
|
|
221
|
-
if (globalAttributeValues.featureMap !== undefined) {
|
|
222
|
-
reportedFeatures = globalAttributeValues.featureMap;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const result: any = {
|
|
227
|
-
id: clusterId,
|
|
228
|
-
name,
|
|
229
|
-
revision: globalAttributeValues?.clusterRevision ?? revision,
|
|
230
|
-
_type: "ClusterClient",
|
|
231
|
-
supportedFeatures: reportedFeatures ?? supportedFeatures ?? {},
|
|
232
|
-
isUnknown: unknown,
|
|
233
|
-
endpointId,
|
|
234
|
-
attributes,
|
|
235
|
-
events,
|
|
236
|
-
commands,
|
|
237
|
-
subscribeAllAttributes: async (options: {
|
|
238
|
-
minIntervalFloorSeconds: number;
|
|
239
|
-
maxIntervalCeilingSeconds: number;
|
|
240
|
-
keepSubscriptions?: boolean;
|
|
241
|
-
isFabricFiltered?: boolean;
|
|
242
|
-
eventFilters?: TypeFromSchema<typeof TlvEventFilter>[];
|
|
243
|
-
dataVersionFilters?: { endpointId: EndpointNumber; clusterId: ClusterId; dataVersion: number }[];
|
|
244
|
-
}) => {
|
|
245
|
-
if (isGroupAddress) {
|
|
246
|
-
throw new ImplementationError("Group cluster clients do not support subscribing attributes");
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
const {
|
|
250
|
-
minIntervalFloorSeconds,
|
|
251
|
-
maxIntervalCeilingSeconds,
|
|
252
|
-
keepSubscriptions,
|
|
253
|
-
isFabricFiltered,
|
|
254
|
-
eventFilters,
|
|
255
|
-
dataVersionFilters,
|
|
256
|
-
} = options;
|
|
257
|
-
|
|
258
|
-
return interactionClient.subscribeMultipleAttributesAndEvents({
|
|
259
|
-
attributes: [{ endpointId: endpointId, clusterId: clusterId }],
|
|
260
|
-
events: [{ endpointId: endpointId, clusterId: clusterId }],
|
|
261
|
-
minIntervalFloorSeconds,
|
|
262
|
-
maxIntervalCeilingSeconds,
|
|
263
|
-
keepSubscriptions,
|
|
264
|
-
isFabricFiltered,
|
|
265
|
-
eventFilters,
|
|
266
|
-
dataVersionFilters,
|
|
267
|
-
attributeListener: attributeData => {
|
|
268
|
-
const { path, value } = attributeData;
|
|
269
|
-
result._triggerAttributeUpdate(path.attributeId, value);
|
|
270
|
-
},
|
|
271
|
-
eventListener: eventData => {
|
|
272
|
-
const { path, events: newEvents } = eventData;
|
|
273
|
-
result._triggerEventUpdate(path.eventId, newEvents);
|
|
274
|
-
},
|
|
275
|
-
});
|
|
276
|
-
},
|
|
277
|
-
|
|
278
|
-
/** Trigger a value change for an Attributed, used by subscriptions. */
|
|
279
|
-
_triggerAttributeUpdate(attributeId: AttributeId, value: any) {
|
|
280
|
-
const attributeName = attributeToId[attributeId];
|
|
281
|
-
if (attributeName === undefined) {
|
|
282
|
-
logger.warn("Unknown attribute id", attributeId);
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
if ((attributes as any)[attributeName] !== undefined) {
|
|
286
|
-
(attributes as any)[attributeName].update(value);
|
|
287
|
-
} else {
|
|
288
|
-
logger.warn("Attribute not found", attributeName, "in list", Object.keys(attributes));
|
|
289
|
-
}
|
|
290
|
-
},
|
|
291
|
-
|
|
292
|
-
/** Trigger a value change for an Event, used by subscriptions. */
|
|
293
|
-
_triggerEventUpdate(eventId: EventId, eventData: DecodedEventData<any>[]) {
|
|
294
|
-
const eventName = eventToId[eventId];
|
|
295
|
-
if (eventName === undefined) {
|
|
296
|
-
logger.warn("Unknown event id", eventId);
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
if ((events as any)[eventName] !== undefined) {
|
|
300
|
-
const event = (events as any)[eventName];
|
|
301
|
-
eventData.forEach(data => event.update(data));
|
|
302
|
-
} else {
|
|
303
|
-
logger.warn("Event not found", eventName, "in list", Object.keys(events));
|
|
304
|
-
}
|
|
305
|
-
},
|
|
306
|
-
|
|
307
|
-
isAttributeSupported: (attributeId: AttributeId) => {
|
|
308
|
-
if (isGroupAddress) {
|
|
309
|
-
throw new ImplementationError("Group cluster clients do not allow to determine attribute existence.");
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
return !!globalAttributeValues?.attributeList?.includes(attributeId);
|
|
313
|
-
},
|
|
314
|
-
|
|
315
|
-
isAttributeSupportedByName: (attributeName: string) => {
|
|
316
|
-
if (isGroupAddress) {
|
|
317
|
-
throw new ImplementationError("Group cluster clients do not allow to determine attribute existence.");
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
const attribute = (attributes as any)[attributeName];
|
|
321
|
-
if (attribute === undefined) {
|
|
322
|
-
return false;
|
|
323
|
-
}
|
|
324
|
-
return !!globalAttributeValues?.attributeList?.includes(attribute.id);
|
|
325
|
-
},
|
|
326
|
-
|
|
327
|
-
isCommandSupported: (commandId: CommandId) => {
|
|
328
|
-
if (isGroupAddress) {
|
|
329
|
-
throw new ImplementationError("Group cluster clients do not allow to determine command existence.");
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
return !!globalAttributeValues?.acceptedCommandList?.includes(commandId);
|
|
333
|
-
},
|
|
334
|
-
|
|
335
|
-
isCommandSupportedByName: (commandName: string) => {
|
|
336
|
-
if (isGroupAddress) {
|
|
337
|
-
throw new ImplementationError("Group cluster clients do not allow to determine attribute existence.");
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
const command = commandDef[commandName];
|
|
341
|
-
if (command === undefined) {
|
|
342
|
-
return false;
|
|
343
|
-
}
|
|
344
|
-
return !!globalAttributeValues?.acceptedCommandList?.includes(command.requestId);
|
|
345
|
-
},
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
const attributeToId = <{ [key: AttributeId]: string }>{};
|
|
349
|
-
|
|
350
|
-
const allAttributeDefs = Merge<T["attributes"], GlobalAttributes<T["features"]>>(
|
|
351
|
-
attributeDef,
|
|
352
|
-
GlobalAttributes(features),
|
|
353
|
-
);
|
|
354
|
-
|
|
355
|
-
// Add accessors from definition
|
|
356
|
-
for (const attributeName in allAttributeDefs) {
|
|
357
|
-
addAttributeToResult(allAttributeDefs[attributeName], attributeName);
|
|
358
|
-
}
|
|
359
|
-
if (globalAttributeValues?.attributeList !== undefined) {
|
|
360
|
-
// Add accessors for potential unknown data
|
|
361
|
-
for (const attributeId of globalAttributeValues.attributeList) {
|
|
362
|
-
if (attributeToId[attributeId] === undefined) {
|
|
363
|
-
const attribute = UnknownAttribute(attributeId);
|
|
364
|
-
addAttributeToResult(attribute, `unknownAttribute_${Diagnostic.hex(attributeId)}`);
|
|
365
|
-
logger.info(
|
|
366
|
-
`Added unknown attribute ${Diagnostic.hex(attributeId)} to cluster ${Diagnostic.hex(clusterId)}`,
|
|
367
|
-
);
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
const eventToId = <{ [key: EventId]: string }>{};
|
|
373
|
-
|
|
374
|
-
// add events
|
|
375
|
-
for (const eventName in eventDef) {
|
|
376
|
-
addEventToResult(eventDef[eventName], eventName);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
const commandToId = <{ [key: CommandId]: string }>{};
|
|
380
|
-
|
|
381
|
-
// Add command calls
|
|
382
|
-
for (const commandName in commandDef) {
|
|
383
|
-
const { requestId } = commandDef[commandName];
|
|
384
|
-
|
|
385
|
-
commandToId[requestId] = commandName;
|
|
386
|
-
commands[commandName as keyof T["commands"]] = async <RequestT, ResponseT>(
|
|
387
|
-
request: RequestT,
|
|
388
|
-
options: {
|
|
389
|
-
asTimedRequest?: boolean;
|
|
390
|
-
timedRequestTimeout?: Duration;
|
|
391
|
-
expectedProcessingTime?: Duration;
|
|
392
|
-
useExtendedFailSafeMessageResponseTimeout?: boolean;
|
|
393
|
-
} = {},
|
|
394
|
-
) => {
|
|
395
|
-
const {
|
|
396
|
-
asTimedRequest,
|
|
397
|
-
timedRequestTimeout,
|
|
398
|
-
useExtendedFailSafeMessageResponseTimeout,
|
|
399
|
-
expectedProcessingTime,
|
|
400
|
-
} = options;
|
|
401
|
-
if (isGroupAddress) {
|
|
402
|
-
return interactionClient.invokeWithSuppressedResponse<Command<RequestT, ResponseT, any>>({
|
|
403
|
-
clusterId,
|
|
404
|
-
command: commandDef[commandName],
|
|
405
|
-
request,
|
|
406
|
-
asTimedRequest,
|
|
407
|
-
timedRequestTimeout,
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
return interactionClient.invoke<Command<RequestT, ResponseT, any>>({
|
|
411
|
-
endpointId: endpointId!,
|
|
412
|
-
clusterId,
|
|
413
|
-
command: commandDef[commandName],
|
|
414
|
-
request,
|
|
415
|
-
asTimedRequest,
|
|
416
|
-
timedRequestTimeout,
|
|
417
|
-
expectedProcessingTime,
|
|
418
|
-
useExtendedFailSafeMessageResponseTimeout,
|
|
419
|
-
});
|
|
420
|
-
};
|
|
421
|
-
commands[requestId as unknown as keyof T["commands"]] = commands[commandName as keyof T["commands"]];
|
|
422
|
-
result[commandName] = result.commands[commandName];
|
|
423
|
-
}
|
|
424
|
-
if (globalAttributeValues?.acceptedCommandList !== undefined) {
|
|
425
|
-
for (const requestId of globalAttributeValues.acceptedCommandList) {
|
|
426
|
-
if (commandToId[requestId] === undefined) {
|
|
427
|
-
logger.info(`Ignoring unknown command ${requestId} at cluster ${Diagnostic.hex(clusterId)}`);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
return result as ClusterClientObj<T>;
|
|
433
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { Duration, ImplementationError } from "#general";
|
|
8
|
-
import { ClusterId, EndpointNumber, Event, EventId, EventNumber } from "#types";
|
|
9
|
-
import { DecodedEventData } from "../../interaction/EventDataDecoder.js";
|
|
10
|
-
import { InteractionClient } from "../../interaction/InteractionClient.js";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Factory function to create an EVentClient for a given event.
|
|
14
|
-
*/
|
|
15
|
-
export function createEventClient<T>(
|
|
16
|
-
event: Event<T, any>,
|
|
17
|
-
name: string,
|
|
18
|
-
endpointId: EndpointNumber | undefined,
|
|
19
|
-
clusterId: ClusterId,
|
|
20
|
-
interactionClient: InteractionClient,
|
|
21
|
-
): EventClient<T> {
|
|
22
|
-
return new EventClient(event, name, endpointId, clusterId, interactionClient);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* General class for EventClients
|
|
27
|
-
*/
|
|
28
|
-
export class EventClient<T> {
|
|
29
|
-
readonly #listeners = new Array<(event: DecodedEventData<T>) => void>();
|
|
30
|
-
readonly id: EventId;
|
|
31
|
-
readonly #interactionClient: InteractionClient;
|
|
32
|
-
|
|
33
|
-
constructor(
|
|
34
|
-
readonly event: Event<T, any>,
|
|
35
|
-
readonly name: string,
|
|
36
|
-
readonly endpointId: EndpointNumber | undefined,
|
|
37
|
-
readonly clusterId: ClusterId,
|
|
38
|
-
interactionClient: InteractionClient,
|
|
39
|
-
) {
|
|
40
|
-
this.id = event.id;
|
|
41
|
-
this.#interactionClient = interactionClient;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async get(
|
|
45
|
-
minimumEventNumber?: EventNumber,
|
|
46
|
-
isFabricFiltered?: boolean,
|
|
47
|
-
): Promise<DecodedEventData<T>[] | undefined> {
|
|
48
|
-
if (this.endpointId === undefined) {
|
|
49
|
-
throw new ImplementationError("Cannot read event without endpointId");
|
|
50
|
-
}
|
|
51
|
-
return await this.#interactionClient.getEvent({
|
|
52
|
-
endpointId: this.endpointId,
|
|
53
|
-
clusterId: this.clusterId,
|
|
54
|
-
event: this.event,
|
|
55
|
-
minimumEventNumber,
|
|
56
|
-
isFabricFiltered,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async subscribe(
|
|
61
|
-
minIntervalFloor: Duration,
|
|
62
|
-
maxIntervalCeiling: Duration,
|
|
63
|
-
isUrgent = true,
|
|
64
|
-
minimumEventNumber?: EventNumber,
|
|
65
|
-
isFabricFiltered?: boolean,
|
|
66
|
-
) {
|
|
67
|
-
if (this.endpointId === undefined) {
|
|
68
|
-
throw new ImplementationError("Cannot read event without endpointId");
|
|
69
|
-
}
|
|
70
|
-
return await this.#interactionClient.subscribeEvent({
|
|
71
|
-
endpointId: this.endpointId,
|
|
72
|
-
clusterId: this.clusterId,
|
|
73
|
-
event: this.event,
|
|
74
|
-
minIntervalFloor,
|
|
75
|
-
maxIntervalCeiling,
|
|
76
|
-
isUrgent,
|
|
77
|
-
minimumEventNumber,
|
|
78
|
-
isFabricFiltered,
|
|
79
|
-
listener: this.update.bind(this),
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
update(newEvent: DecodedEventData<T>) {
|
|
84
|
-
for (const listener of this.#listeners) {
|
|
85
|
-
listener(newEvent);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
addListener(listener: (newValue: DecodedEventData<T>) => void) {
|
|
90
|
-
this.#listeners.push(listener);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
removeListener(listener: (newValue: DecodedEventData<T>) => void) {
|
|
94
|
-
const entryIndex = this.#listeners.indexOf(listener);
|
|
95
|
-
if (entryIndex !== -1) {
|
|
96
|
-
this.#listeners.splice(entryIndex, 1);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|