Sessions (real-time-collaboration/realtimecollaborativeediting)
@ckeditor/ckeditor5-real-time-collaboration/src/realtimecollaborativeediting/sessions
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
module:real-time-collaboration/realtimecollaborativeediting/sessions~Sessions#allConnectedUsers
readonly
A collection of users currently connected to all channels.
-
channelConnectedUsers : Map.<String, Collection>
module:real-time-collaboration/realtimecollaborativeediting/sessions~Sessions#channelConnectedUsers
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>
module:real-time-collaboration/realtimecollaborativeediting/sessions~Sessions#channelSessions
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
module:real-time-collaboration/realtimecollaborativeediting/sessions~Sessions#mySessionId
Session id of the current client.
Methods
-
getUserBySessionId( sessionId ) → Users
module:real-time-collaboration/realtimecollaborativeediting/sessions~Sessions#getUserBySessionId
Returns a reference to the user connected with a session with the given ID.
-
getUserRole( user ) → String
module:real-time-collaboration/realtimecollaborativeediting/sessions~Sessions#getUserRole
Returns the role of a given user.
-
getUserSessions( user, [ channelId ] ) → Set.<String>
module:real-time-collaboration/realtimecollaborativeediting/sessions~Sessions#getUserSessions
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 )
module:real-time-collaboration/realtimecollaborativeediting/sessions~Sessions#register
Observes given service sessions and updates session and users according to it.
Parameters
channelId : String
serviceSessions : Collection
-
unregister( channelId )
module:real-time-collaboration/realtimecollaborativeediting/sessions~Sessions#unregister
Stops observing given service sessions and remove all related sessions and users.
Parameters
channelId : String
Every day, we work hard to keep our documentation complete. Have you spotted an outdated information? Is something missing? Please report it via our issue tracker.