Sprotty
Toggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

Class. Diagram Server

sprotty-protocol / DiagramServer

Class: DiagramServer

Defined in: diagram-server.ts:31

An instance of this class is responsible for handling a single diagram client. It holds the current state of the diagram and manages communication with the client via actions.

Constructors

Constructor

new DiagramServer(dispatch, services): DiagramServer

Defined in: diagram-server.ts:49

Parameters

dispatch

<A>(action) => Promise<void>

services

DiagramServices

Returns

DiagramServer

Properties

actionHandlerRegistry?

protected optional actionHandlerRegistry: ServerActionHandlerRegistry

Defined in: diagram-server.ts:46


diagramGenerator

protected readonly diagramGenerator: IDiagramGenerator

Defined in: diagram-server.ts:44


dispatch()

readonly dispatch: <A>(action) => Promise<void>

Defined in: diagram-server.ts:42

Type Parameters

A

A extends Action

Parameters

action

A

Returns

Promise<void>


layoutEngine?

protected readonly optional layoutEngine: IModelLayoutEngine

Defined in: diagram-server.ts:45


requests

protected readonly requests: Map<string, Deferred<ResponseAction>>

Defined in: diagram-server.ts:47


state

readonly state: DiagramState & object

Defined in: diagram-server.ts:33

Type declaration

lastSubmittedModelType?

optional lastSubmittedModelType: string

Accessors

needsClientLayout

Get Signature

get needsClientLayout(): boolean

Defined in: diagram-server.ts:83

Whether the client needs to compute the layout of parts of the model. This affects the behavior of submitModel.

This setting is determined by the DiagramOptions that are received with the RequestModelAction from the client. If the client does not specify whether it needs client layout, the default value is true.

Returns

boolean


needsServerLayout

Get Signature

get needsServerLayout(): boolean

Defined in: diagram-server.ts:98

Whether the server needs to compute the layout of parts of the model. This affects the behavior of submitModel.

This setting is determined by the DiagramOptions that are received with the RequestModelAction from the client. If the client does not specify whether it needs server layout, the default value is false.

Returns

boolean

Methods

accept()

accept(action): Promise<void>

Defined in: diagram-server.ts:108

Called when an action is received from the client.

Parameters

action

Action

Returns

Promise<void>


handleAction()

protected handleAction(action): Promise<void>

Defined in: diagram-server.ts:160

Parameters

action

Action

Returns

Promise<void>


handleComputedBounds()

protected handleComputedBounds(action): Promise<void>

Defined in: diagram-server.ts:242

Parameters

action

ComputedBoundsAction

Returns

Promise<void>


handleLayout()

protected handleLayout(action): Promise<void>

Defined in: diagram-server.ts:250

Parameters

action

LayoutAction

Returns

Promise<void>


handleRequestModel()

protected handleRequestModel(action): Promise<void>

Defined in: diagram-server.ts:182

Parameters

action

RequestModelAction

Returns

Promise<void>


rejectRemoteRequest()

rejectRemoteRequest(action, error): void

Defined in: diagram-server.ts:149

Send a RejectAction to the client to notify that a request could not be fulfilled.

Parameters

action

undefined | Action

error

Error

Returns

void


request()

request<Res>(action): Promise<Res>

Defined in: diagram-server.ts:132

Send a request action to the client. The resulting promise is resolved when a matching response is received and rejected when a RejectAction is received.

Type Parameters

Res

Res extends ResponseAction

Parameters

action

RequestAction<Res>

Returns

Promise<Res>


setModel()

setModel(newRoot): Promise<void>

Defined in: diagram-server.ts:60

Set the model and submit it to the client.

Parameters

newRoot

SModelRoot

Returns

Promise<void>


submitModel()

protected submitModel(newRoot, update, cause?): Promise<void>

Defined in: diagram-server.ts:201

Submit a model to the client after it has been updated in the server state.

Parameters

newRoot

SModelRoot

update

boolean

cause?

Action

Returns

Promise<void>


updateModel()

updateModel(newRoot): Promise<void>

Defined in: diagram-server.ts:69

Update the model to a new state and submit it to the client.

Parameters

newRoot

SModelRoot

Returns

Promise<void>