Options
Menu

Class ActivityService

The ActivityService provides the main entry point into working with Activities in Convergence. Activities provide a mechanism to communicate where users are operating within a system and what they are doing.

See the developer guide for an introduction to Activities.

Hierarchy

Index

Methods

addListener

create

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.

isJoined

  • isJoined(type: string, id: string): boolean
  • Determines if an Activity with the specified id is already joined.

    Parameters

    • type: string

      The user defined type of activity.

    • id: string

      The id (unique within the type) of the Activity to check.

    Returns boolean

    True if the Activity with the specified id is joined; false otherwise.

join

  • Allows the connected user to join the specified activity.

    const activityId = "myActivityId";
    activityService
      .join(activityId)
      .then(activity => {
        console.log("Joined!");
        console.log(activity.participants());
      });
      .catch(e => console.error(e));
    

    Parameters

    • type: string

      The user defined type of the Activity to join.

    • id: string

      The unique id (within the type) of the Activity to join.

    • options: IActivityJoinOptions

      Options for connecting to the specified Activity.

    Returns Promise<Activity>

    A Promise that will be resolved with the successfully joined Activity.

joined

  • Provides a map of all currently joined Activities.

    Returns Map<string, Activity>

    A Map of Activity Id => Activity.

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.

remove

  • remove(activityId: string, activityType?: string): Promise<void>
  • Parameters

    • activityId: string
    • activityType: string

    Returns Promise<void>

removeAllListeners

removeListener

removeListeners

session

  • Returns ConvergenceSession

    The current Convergence ConvergenceSession object that represents the connection to the Convergence Domain.