Class

Sessions (real-time-collaboration/realtimecollaborativeediting)

@ckeditor/ckeditor5-real-time-collaboration/src/realtimecollaborativeediting/sessions

class

The Sessions plugin stores the information about the users and sessions connected to the rich text editor.

The difference between the sessions plugin and the Users plugin is that Users also keeps information about the users who are not currently connected to the editor (for example, a comment author who is currently offline).

If your integration uses Context and there are multiple channels used, the Sessions plugin aggregates users connected to all the channels.

There are two types of entries in the sessions plugin: connected users and sessions.

There is one session for each connection to a given channel. For example, for each open editor instance connecting to a given channel ID, there will be a session. Every session has a user. However, the same user can be linked with multiple sessions (for example, the same user opened the same URL in multiple tabs).

In other words, if the same user (with the same user ID) opens the same document in two different tabs, they will create two sessions but only one user will be connected. You will be able to see two selections in the same document, both in the same color, but only a single user in the user presence list.

Filtering

Properties

  • allConnectedUsers : Collection

    readonly

    A collection of users currently connected to all channels.

  • channelConnectedUsers : Map.<String, Collection>

    readonly

    A map of user collections connected to the separate channels.

    The keys of the map are channel IDs and the values are collections of users.

  • channelSessions : Map.<String, Collection>

    readonly

    A map of session collections connected to the separate channels.

    The keys of the map are channel IDs and the values are collections of sessions.

    A session is represented by an object with the following properties:

    • id - A unique session ID.
    • user - A reference to the user.
  • mySessionId : String

    Session id of the current client.

Methods

  • getUserBySessionId( sessionId ) → Users

    Returns a reference to the user connected with a session with the given ID.

    Parameters

    sessionId : String

    Returns

    Users
  • getUserRole( user ) → String

    Returns the role of a given user.

    Parameters

    user : Users

    The user object.

    Returns

    String
  • getUserSessions( user, [ channelId ] ) → Set.<String>

    Returns a set of ids of all currently connected sessions for the given user.

    When one user is connected to the same document in two separate browser tabs then this users belongs to the two sessions.

    Optionally the result can be limited to the given channelId.

    Parameters

    user : Users

    The user object.

    [ channelId ] : String

    Returns

    Set.<String>
  • register( channelId, serviceSessions )

    Observes given service sessions and updates session and users according to it.

    Parameters

    channelId : String
    serviceSessions : Collection
  • unregister( channelId )

    Stops observing given service sessions and remove all related sessions and users.

    Parameters

    channelId : String