Server implementation of NetworkBehavior.

This behavior mostly deals with configuration and events. NetworkServer provides the actual network implementation.

Hierarchy (view full)

Constructors

Properties

events: EventEmitter

Access the behavior's events.

internal: Internal
state: State

Access the behavior's state.

dependencies?: Iterable<Type, any, any>

Explicitly reference other Behaviors as dependencies, ensuring this behavior is destroyed first.

This probably won't be commonly necessary. If it is we can instrument Agent to collect dependencies automatically.

early = true

By default behaviors load lazily as they are accessed. You can set this flag to true to force behaviors to load immediately when the endpoint initializes.

Events: typeof EventEmitter

Implementation of the events property. Subclasses may override to extend.

id = "network"

Each behavior implementation has an ID that uniquely identifies the type of behavior. An Endpoint may only have one behavior with the specified ID.

Endpoint instances store each behavior in a property with the same name as the behavior's ID.

EndpointBuilder also uses the ID when replacing behaviors using the with() builder method.

schema?: Schema

A behavior's schema controls access to data, commands and events.

Schema is inferred from the methods and properties of the behavior but you can specify explicitly for additional control.

Accessors

  • get [reference](): Datasource<StateType>
  • Returns Datasource<StateType>

  • get agent(): Agent
  • The agent that owns the behavior.

    Returns Agent

  • get context(): ActionContext
  • The context in which the behavior operates.

    Returns ActionContext

  • get endpoint(): Endpoint<Empty>
  • The endpoint that owns behavior's agent.

    Returns Endpoint<Empty>

  • get env(): Environment
  • The endpoint's environment.

    Returns Environment

  • get session(): SecureSession
  • The session in which the behavior has been invoked.

    Returns SecureSession

  • get defaults(): Record<string, any>
  • Default state values.

    Returns Record<string, any>

  • get supervisor(): RootSupervisor
  • The data supervisor for the behavior. The supervisor controls validation and access to behavior data.

    Returns RootSupervisor

Methods

  • Release resources. This is the public API for releasing application resources held by behaviors in internal state.

    Returns undefined | Promise<void>

  • Immediately broadcast presence to the network regardless of whether the advertisement window is open.

    Returns void

  • Execute logic with elevated privileges.

    The provided function executes with privileges escalated to offline mode. This is not commonly necessary.

    Elevated logic effectively ignores ACLs so should be used with care.

    Note that interactions with the behavior will remain elevated until the synchronous completion of this call. You should only elevate privileges for synchronous logic.

    Parameters

    • fn: (() => void)

      the elevated logic

        • (): void
        • Returns void

    Returns void

  • Create a generic callback function that has the same properties as a Reactor.

    Like a reactor, the callback's "this" will be bound to an active Behavior instance. Because of this: The reactor MUST be a real JS function - arrow functions will not work!

    Type Parameters

    • A extends any[]
    • R

    Parameters

    Returns ((...args: A) => undefined | R)

      • (...args): undefined | R
      • Parameters

        • Rest...args: A

        Returns undefined | R

  • Behaviors are ephemeral and should not perform initialization in their constructor. They can override this method instead.

    This method may be synchronous or asyncronous. If asynchronous, the behavior will not be available for external use until initialization completes.

    Returns MaybePromise<void>

  • Advertise and continue advertising at regular intervals until timeout per Matter specification. If already advertising, the advertisement timeout resets.

    If the node is uncommissioned and commissioning is enabled, announces as commissionable on all available transports. Commissioned devices only advertise for operational discovery via DNS-SD.

    Advertisement begins at startup.

    Returns void

  • Install a Reactor.

    Important: The reactor MUST be a real JS function - arrow functions will not work!

    Type Parameters

    Parameters

    Returns void

  • Description used in diagnostic messages.

    Returns string

  • Create a new behavior with different default state values.

    Type Parameters

    Parameters

    Returns This

  • Does this behavior support functionality of a specific implementation?

    Parameters

    Returns boolean