Skip to main content

Web Collaboration Server

Overview

Web Collaboration Server is available as a NPM package: @foxitsoftware/web-collab-server. You also can get it from the Collaboration Add-on Package.

Web Collaboration Server supports two modes: Simple Mode and Cluster Mode.

In simple mode, collaboration server runs on a single-instance basis, with only one collaboration server instance. The configuration is easy in this mode, you just need to configure UserService and Database.

In cluster mode, multiple collaboration servers can be started to form a cluster to handle users requests together. For more information about cluster mode, please refer to Cluster.

Simple Mode

Before running collaboration server, you need to set up the database and user service.

Set up Database

Please refer to Database to set up the database.

Set up User Service

Please refer to Authentication to set up user service, such as user authentication and user information acquisition.

Start a Collaboration Server

Install collaboration server using NPM:

npm install @foxitsoftware/web-collab-server

Create a collaboration server referring to the following code:

import {WebCollabServer, UserService} from "@foxitsoftware/web-collab-server";

// UserService should be implemented by user App
const userService: UserService = {
getUserByToken(token) {
// validate token and get uesr info from user system of client APP
}
}

const databaseConfig = {
type: 'postgres',
host: 'localhost',
port: 5432,
database: 'collab-db',
user: 'foxit',
password: '123456',
}

const server = new WebCollabServer({
databaseConfig,
userService,
});

server.start(8080)

Cluster Mode

To enable the clustering, provide the cluster option when creating WebCollabServer. Only serverId is required if you want to use the default implementation.

MessageQueue and MemberStateService can be implemented if you want more customization.

Notice:

The 'serverId' of the server instance in the same cluster should be unique. Refer to serverId for more information.

const messageQueue = new CustomMessageQueue()
const memberStateService = new CustomMemberStateService()

const server = new WebCollabServer({
databaseConfig,
userService,
cluster: {
serverId: '1',
messageQueue, // only required if you want to use your customized MessageQueue
memberStateService // only required if you want to use your customized MemberStateService
}
});