Options
All
  • Public
  • Public/Protected
  • All
Menu

Live fluid object that broadcasts an event to other clients and a set of static event related helpers.

remarks

Applications should call on('received', (evt, local) => {}) to listen for local events sent and remote events received. Events aren't guaranteed to be delivered so you should limit their use to sending events you're ok with potentially being missed. Reactions are a good use case for LiveEvents. Use something like the LiveState class when syncing state.

Type Parameters

Hierarchy

Index

Constructors

  • Type Parameters

    Parameters

    Returns LiveEvent<TEvent>

Properties

TypeName: "@microsoft/live-share:LiveEvent" = ...

The objects fluid type/name.

factory: DataObjectFactory<LiveEvent<ILiveEvent>, DataObjectTypes> = ...

The objects fluid type factory.

Accessors

  • get isInitialized(): boolean
  • get isStarted(): boolean

Methods

  • sendEvent(evt?: Partial<TEvent>): TEvent
  • Broadcasts an event to all other clients.

    remarks

    The event will be queued for delivery if the client isn't currently connected.

    Parameters

    • Optional evt: Partial<TEvent>

      Optional. Event to send. If omitted, an event will still be sent but it won't include any custom event data.

    Returns TEvent

    The full event object that was sent, including the timestamp of when the event was sent and the clientId if known. The clientId will be undefined if the client is disconnected at time of delivery.

  • getTimestamp(): number
  • Returns true if a received event is newer then the current event.

    remarks

    Used when building new Live objects to process state change events. The isNewer() method implements an algorithm that deals with conflicting events that have the same timestamp and older events that should have debounced the current event.

    • When the received event has the same timestamp as the current event, each events clientId will be used as a tie breaker. The clientId containing the lower sort order wins any ties.
    • Older events are generally ignored unless a debounce period is specified. An older event that should have debounced the current event will be considered newer.

    The algorithm employed by isNewer() helps ensure that all clients will eventually reach a consistent state with one other.

    Parameters

    • current: undefined | IClientTimestamp

      Current event to compare received event against.

    • received: IClientTimestamp

      Received event.

    • debouncePeriod: number = 0

      Optional. Time in milliseconds to ignore any new events for. Defaults to 0 ms.

    Returns boolean

    True if the received event is newer then the current event and should replace the current one.

  • verifyRolesAllowed(clientId: string, allowedRoles: UserMeetingRole[]): Promise<boolean>
  • Verifies that a client has one of the specified roles.

    Parameters

    • clientId: string

      Client ID to inspect.

    • allowedRoles: UserMeetingRole[]

      User roles that are allowed.

    Returns Promise<boolean>

    True if the client has one of the specified roles.

Generated using TypeDoc