Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Activity

The Activity class represents a activity that the users of a collaboration are participating in together. The activity allows developer to indicate what user are doing within a collaborative application. The activity has a set of participants that indicate which users are part of that activity. Each ActivityParticipant can share state which indicates what they are doing within the Activity.

Hierarchy

Index

Methods

addListener

clearState

  • clearState(): void
  • Removes all local state from this Activity.

    Returns void

events

  • Provides the events emitted by this object as an Observable stream.

    example
    
    eventEmitter.events()
      .filter(e => e.name === "myevent")
      .subscribe(e => console.log(e));

    Returns Observable<IActivityEvent>

    An Observable stream of all events emitted by this object.

id

  • id(): string

isJoined

  • isJoined(): boolean
  • Determines if the Activity is still joined.

    Returns boolean

    True if the Activity is joined, false otherwise.

leave

  • leave(): void
  • Causes the local session to leave the Activity. All other participants of this activity will be notified that this session has left. The state associated with this session will be removed from eh Activity. After calling leave, the Activity object becomes non-functional. The local user can rejoin the activity from the ActivityService but will receive a new Activity object.

    Returns void

off

on

once

  • Adds a single shot event listener for the specified event. The listener will be called the first time the specified event is fired after the event registration occurs, after which the registration will be removed and no further events will be passed to the listener.

    Parameters

    Returns ConvergenceEventEmitter<IActivityEvent>

    This object, in support of a fluent API.

participant

participants

participantsAsObservable

  • Gets the participants as an Observable stream.

    activity
      .participantsAsObservable()
      .subscribe(p => console.log(p));

    Returns Observable<ActivityParticipant[]>

    An Observable array of participants.

removeAllListeners

removeListener

removeListeners

removeState

  • removeState(key: string): void
  • removeState(keys: string[]): void
  • Removes a single local state entry from the Activity.

    activity.removeState("pointer");

    Parameters

    • key: string

      The key of the local state to remove.

    Returns void

  • Removes one or more local state entries from the Activity.

    activity.removeState(["pointer", "viewport"]);

    Parameters

    • keys: string[]

      The keys of the local state to remove.

    Returns void

session

setState

  • setState(key: string, value: any): void
  • setState(state: StringMapLike): void
  • Sets a single key-value pair within this Activity's local state.

    activity.setState("key1", "value");

    Parameters

    • key: string

      The key of the value to set.

    • value: any

      The value to set for the supplied key.

    Returns void

  • Sets multiple key-value pairs within this Activity's local state. This method does not replace all state; that is, keys not supplied in the map will not be altered.

    const state = {
      key1: "v1",
      key2: false
    };
    activity.setState(state);

    or

    const state = new Map();
    state.set("key1", "v1");
    state.set("key2", false);
    activity.setState(state);

    Parameters

    • state: StringMapLike

      A map containing the key-value pairs to set.

    Returns void

state

  • state(): Map<string, any>
  • Gets the local session's state within this Activity.

    Returns Map<string, any>

    The local sessions state.

Object literals

Static Events

Events: object

Holds the constants for the event names that are fired by the Activity class.

SESSION_JOINED

SESSION_JOINED: string = ActivitySessionJoinedEvent.EVENT_NAME

Fired when a remote session joins the activity. The resulting event will be an instance of the ActivitySessionJoinedEvent class.

SESSION_LEFT

SESSION_LEFT: string = ActivitySessionLeftEvent.EVENT_NAME

Fired when a remote session leaves the activity. The resulting event will be an instance of the ActivitySessionLeftEvent class.

STATE_CLEARED

STATE_CLEARED: string = ActivityStateClearedEvent.EVENT_NAME

Fired when a remote session clears state within the Activity. The resulting event will be an instance of the ActivityStateClearedEvent class.

STATE_REMOVED

STATE_REMOVED: string = ActivityStateRemovedEvent.EVENT_NAME

Fired when a remote session clears state within the Activity. The resulting event will be an instance of the ActivityStateRemovedEvent class.

STATE_SET

STATE_SET: string = ActivityStateSetEvent.EVENT_NAME

Fired when a remote session sets state within the Activity. The resulting event will be an instance of the ActivityStateSetEvent class.