[]
        
(Showing Draft Content)

Server

Class: Server

Represents a collaboration server, provides bidirectional communication, middleware and hooks mechanism.

Table of contents

Constructors

Methods

Constructors

constructor

new Server(config?)

Parameters

Name Type
config? IServerConfig

Methods

on

on(hooks): void

Registers multiple hooks to the server in a batch.

Parameters

Name Type Description
hooks IHooks The hooks to register.

Returns

void

on<K>(action, hook): void

Registers a single hook for a specific action on the server.

Type parameters

Name Type Description
K extends keyof IHookContext Type of the action name, extending keyof IHookContext.

Parameters

Name Type Description
action K he name of the action to associate with the hook
hook IHook<IHookContext[K]> The hook to register for the specified action.

Returns

void


use

use(middlewares): void

Registers multiple middlewares to the server in a batch.

Parameters

Name Type Description
middlewares IMiddlewares The middlewares to register.

Returns

void

use<K>(action, middleware): void

Registers a single middleware for a specific action on the server.

Type parameters

Name Type Description
K extends keyof IMiddlewareContext Type of the action name, extending keyof IMiddlewareContext.

Parameters

Name Type Description
action K The name of the action to associate with the middleware.
middleware IMiddleware<IMiddlewareContext[K]> The middleware to register for the specified action.

Returns

void


useFeature

useFeature(feature): void

Register feature to the server.

Parameters

Name Type Description
feature IFeature The feature to register.

Returns

void