Adds a new event listener for the specified event. The class will ignore duplicate registrations of the same listener to the same event.
The name of the event to add the listener for.
The listener callback to register.
This object, in support of a fluent API.
Clears all local state from this Activity. This will fire a single "state_cleared" event for other joined participants to listen for.
Provides the events emitted by this object as an Observable stream.
An Observable stream of all events emitted by this object.
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.
Removes a single event listener for a specific event.
The name of the event to remove the listener for.
The listener callback to unregister.
This object, in support of a fluent API.
Adds a new event listener for the specified event. The class will ignore duplicate registrations of the same listener to the same event.
The name of the event to add the listener for.
The listener callback to register.
This object, in support of a fluent API.
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.
The name of the event to add the listener for.
The listener callback to register.
This object, in support of a fluent API.
Gets an ActivityParticipant by their sessionId.
The sessionId of the participant to get.
The ActivityParticipant corresponding to the supplied id, or undefined if no such participant exists.
Gets all participants presently joined to this Activity.
An array of ActivityParticipant objects, one for each joined participant.
Gets the participants as an Observable stream.
activity
.participantsAsObservable()
.subscribe(p => console.log(p));
An Observable array of participants.
Removes all listeners for all events. This is useful for cleanup before disposing of this particular event emitter.
This object, in support of a fluent API.
Removes a single event listener for a specific event.
The name of the event to remove the listener for.
The listener callback to unregister.
This object, in support of a fluent API.
Removes all listeners bound on the given event.
the name of the event to remove listeners for
This object, in support of a fluent API.
Removes a single local state entry from the Activity. This will fire a single "state_removed" event for other joined participants to listen for.
activity.removeState("pointer");
The key of the local state to remove.
Removes one or more local state entries from the Activity. This will fire a multiple "state_removed" event for other joined participants to listen for; one for each key removed.
activity.removeState(["pointer", "viewport"]);
The keys of the local state to remove.
Gets the session that this activity is a part of.
The session that this Activity is a part of.
Sets a single key-value pair within this Activity's local state. This will result in a single "state_set" event being emitted for other joined participants to listen for.
activity.setState("key1", "delta");
The key of the delta to set.
The delta to set for the supplied key.
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. This method will result in multiple "state_set" events being fired for other joined participants to list for; one for each key set.
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);
A mapping containing the key-value pairs to set.
Gets the local session's state within this Activity.
The local sessions state.
Holds the constants for the event names that are fired by the Activity class.
Fired when a the activity was deleted while joined.
Fired when the server forces the local session to leave the activity.
Fired when a the activity is left by the local session. The resulting event will be an ActivityLeftEvent.
Fired when a remote session joins the activity. The resulting event will be an ActivitySessionJoinedEvent.
Fired when a remote session leaves the activity. The resulting event will be an ActivitySessionLeftEvent.
Fired when a remote session clears state within the Activity. The resulting event will be an ActivityStateClearedEvent.
Fired when a remote session makes any changes to state within Activity. The resulting event will be a ActivityStateDeltaEvent.
This is a batch event whereas ActivityStateClearedEvent and ActivityStateSetEvent are fired for individual properties.
Fired when a remote session clears state within the Activity. The resulting event will be an ActivityStateRemovedEvent.
Fired when a remote session sets state within the Activity. The resulting event will be an ActivityStateSetEvent.
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.