Skip to main content

collab_screenSync

Collaboration ScreenSync

The screenSync session can be created on top of the collaboration session and has one "leader" and multiple "followers"

Followers will follow leader’s screen scrolling,PDFPage zooming,and PDFPage view mode.

A collaboration can have multiple active screenSync sessions at once, however a user can only be leading one session at a time, and a user can only be connected to one session at a time.

Create screenSync

First, you need to start a collaboration. During the collaboration, you can create a screenSync session through the collaboration.createScreenSync API.

import { WebCollabClient } from '@foxitsoftware/web-collab-client';

const webCollabClient = new WebCollabClient(CollabOptions);
const collaboration = await webCollabClient.createCollaboration({
fileUrl: 'https://foxit.com/downloads/pl/demo.pdf',
isDocPublic: true,
docName: 'demo.pdf'
})

await collaboration.begin()

const screenSync = await collaboration.createScreenSync(memberIds)
  • memberIds?: The list of member ids of the collaboration which will be invited to be followers of the screenSync session. By default, all members of the current collaboration will be invited to be followers of the screenSync session.
tip

After the screenSync session is successfully created, wait for other members to join. When a member joins, you will become the leader of the screenSync session, and other members will follow you.

Get a screenSync session

When the screenSync session is successfully created, the 'screen-sync-created' event is fired for specified member or all members of the collaboration. You can get a screenSync session with the collaboration.getScreenSync API.

The getScreenSync API gets a specific screenSync via the screenSync id screenSyncId (string).

Example

const screenSync = await collaboration.getScreenSync('screenSyncId');

Get screenSync List

You can get the screenSync list with the collaboration.getScreenSyncList API.

Example

const screenSync = await collaboration.getScreenSyncList();

Join a screenSync session

A screenSync session can be joined by calling the screenSync.join API.

Once you have a screenSync session, join it by calling join().

const screenSync = await collaboration.getScreenSync('screenSyncId');
await screenSync.join()
tip

When you join a screenSync session, you will be a follower of the screenSync. The session leader now controls the screen scrolling, zooming, and PDF layout mode.

Leave a screenSync session

You can leave a screenSync session at any time by calling the screenSync.leave API.

When you leave the current screenSync session, your view will no longer follow the leader's view. If the leaving user is the leader of screenSync, the current screenSync session will be stopped.

const screenSync = await collaboration.getScreenSync('screenSyncId');
await screenSync.leave()

Get screenSync members

You can get screenSync members by the screenSync role with the screenSync.getMembers API. This function can get all the members information under the current screenSync session.

Example

const screenSync = await collaboration.getScreenSync('screenSyncId');
let leader=await screenSync.getMembers('leader')
let followers=await screenSync.getMembers('follower')
let screenSyncMembers=await screenSync.getMembers()