Skip to main content
Version: v1

DocumentDeltaConnection Class

Represents a connection to a stream of delta updates

Signature

export declare class DocumentDeltaConnection extends EventEmitterWithErrorHandling<IDocumentDeltaConnectionEvents> implements IDocumentDeltaConnection, IDisposable

Extends: EventEmitterWithErrorHandling<IDocumentDeltaConnectionEvents

Implements: IDocumentDeltaConnection, IDisposable

Constructors

ConstructorDescription
(constructor)(socket, documentId, logger, enableLongPollingDowngrades)Constructs a new instance of the DocumentDeltaConnection class

Static Properties

PropertyTypeDescription
eventsAlwaysForwardedstring[]
eventsToForwardstring[]

Properties

PropertyAlertsTypeDescription
_disposedbooleanFlag to indicate whether the DocumentDeltaConnection is expected to still be capable of sending messages. After disconnection, we flip this to prevent any stale messages from being emitted.
checkpointSequenceNumbernumber | undefinedLast known sequence number to ordering service at the time of connection It may lap actual last sequence number (quite a bit, if container is very active). But it's best information for client to figure out how far it is behind, at least for "read" connections. "write" connections may use own "join" op to similar information, that is likely to be more up-to-date.
claimsITokenClaimsGet the claims of the client who is sending the message
clientIdstringGet the ID of the client who is sending the message
detailsIConnected
disposedboolean
documentIdstring
earlyOpHandler(documentId: string, msgs: ISequencedDocumentMessage[]) => void
earlySignalHandler(msg: ISignalMessage) => void
existingbooleanGet whether or not this is an existing document
hasDetailsboolean
initialClientsISignalClient[]Get initial client list
initialMessagesISequencedDocumentMessage[]Get messages sent during the connection
initialSignalsISignalMessage[]Get signals sent during the connection
loggerDeprecatedITelemetryLogger
maxMessageSizenumberGet the maximum size of a message before chunking is required
modeConnectionModeGet the mode of the client
queuedMessagesISequencedDocumentMessage[]
queuedSignalsISignalMessage[]
serviceConfigurationIClientConfigurationConfiguration details provided by the service
socketSocket
versionstringSemver of protocol being used with the service

Methods

MethodReturn TypeDescription
addTrackedListener(event, listener)void
createErrorObject(handler, error, canRetry)IAnyDriverErrorError raising for socket.io issues
disconnect(socketProtocolError, reason)voidDisconnect from the websocket.
dispose()voidDisconnect from the websocket, and permanently disable this DocumentDeltaConnection.
disposeCore(socketProtocolError, err)void
emitMessages(type, messages)void
initialize(connectMessage, timeout)Promise<void>
submit(messages)voidSubmits a new delta operation to the server
submitCore(type, messages)void
submitSignal(message)voidSubmits a new signal to the server

Constructor Details

(constructor)

Constructs a new instance of the DocumentDeltaConnection class

Signature

protected constructor(socket: Socket, documentId: string, logger: ITelemetryLogger, enableLongPollingDowngrades?: boolean);

Parameters

ParameterModifiersTypeDescription
socketSocketwebsocket to be used
documentIdstringID of the document
loggerITelemetryLoggerfor reporting telemetry events
enableLongPollingDowngradesoptionalbooleanallow connection to be downgraded to long-polling on websocket failure

Property Details

_disposed

Flag to indicate whether the DocumentDeltaConnection is expected to still be capable of sending messages. After disconnection, we flip this to prevent any stale messages from being emitted.

Signature

protected _disposed: boolean;

Type: boolean

checkpointSequenceNumber

Last known sequence number to ordering service at the time of connection It may lap actual last sequence number (quite a bit, if container is very active). But it's best information for client to figure out how far it is behind, at least for "read" connections. "write" connections may use own "join" op to similar information, that is likely to be more up-to-date.

Signature

checkpointSequenceNumber: number | undefined;

Type: number | undefined

claims

Get the claims of the client who is sending the message

Signature

get claims(): ITokenClaims;

Type: ITokenClaims

clientId

Get the ID of the client who is sending the message

Signature

get clientId(): string;

Type: string

details

Signature

get details(): IConnected;

Type: IConnected

disposed

Signature

get disposed(): boolean;

Type: boolean

documentId

Signature

documentId: string;

Type: string

earlyOpHandler

Signature

protected earlyOpHandler: (documentId: string, msgs: ISequencedDocumentMessage[]) => void;

Type: (documentId: string, msgs: ISequencedDocumentMessage[]) => void

earlySignalHandler

Signature

protected earlySignalHandler: (msg: ISignalMessage) => void;

Type: (msg: ISignalMessage) => void

eventsAlwaysForwarded

Signature

static readonly eventsAlwaysForwarded: string[];

Type: string[]

eventsToForward

Signature

static readonly eventsToForward: string[];

Type: string[]

existing

Get whether or not this is an existing document

Signature

get existing(): boolean;

Type: boolean

hasDetails

Signature

protected get hasDetails(): boolean;

Type: boolean

initialClients

Get initial client list

Signature

get initialClients(): ISignalClient[];

Type: ISignalClient[]

initialMessages

Get messages sent during the connection

Signature

get initialMessages(): ISequencedDocumentMessage[];

Type: ISequencedDocumentMessage[]

initialSignals

Get signals sent during the connection

Signature

get initialSignals(): ISignalMessage[];

Type: ISignalMessage[]

logger

This API is deprecated and will be removed in a future release.
  • Implementors should manage their own logger or monitoring context

Signature

protected get logger(): ITelemetryLogger;

Type: ITelemetryLogger

maxMessageSize

Get the maximum size of a message before chunking is required

Signature

get maxMessageSize(): number;

Type: number

mode

Get the mode of the client

Signature

get mode(): ConnectionMode;

Type: ConnectionMode

queuedMessages

Signature

protected readonly queuedMessages: ISequencedDocumentMessage[];

Type: ISequencedDocumentMessage[]

queuedSignals

Signature

protected readonly queuedSignals: ISignalMessage[];

Type: ISignalMessage[]

serviceConfiguration

Configuration details provided by the service

Signature

get serviceConfiguration(): IClientConfiguration;

Type: IClientConfiguration

socket

Signature

protected readonly socket: Socket;

Type: Socket

version

Semver of protocol being used with the service

Signature

get version(): string;

Type: string

Method Details

addTrackedListener

Signature

protected addTrackedListener(event: string, listener: (...args: any[]) => void): void;

Parameters

ParameterTypeDescription
eventstring
listener(...args: any[]) => void

createErrorObject

Error raising for socket.io issues

Signature

protected createErrorObject(handler: string, error?: any, canRetry?: boolean): IAnyDriverError;

Parameters

ParameterModifiersTypeDescription
handlerstring
erroroptionalany
canRetryoptionalboolean

Returns

Return type: IAnyDriverError

disconnect

Disconnect from the websocket.

Signature

protected disconnect(socketProtocolError: boolean, reason: IAnyDriverError): void;

Parameters

ParameterTypeDescription
socketProtocolErrorbooleantrue if error happened on socket / socket.io protocol level (not on Fluid protocol level)
reasonIAnyDriverErrorreason for disconnect

dispose

Disconnect from the websocket, and permanently disable this DocumentDeltaConnection.

Signature

dispose(): void;

disposeCore

Signature

protected disposeCore(socketProtocolError: boolean, err: IAnyDriverError): void;

Parameters

ParameterTypeDescription
socketProtocolErrorboolean
errIAnyDriverError

emitMessages

Signature

protected emitMessages(type: string, messages: IDocumentMessage[][]): void;

Parameters

ParameterTypeDescription
typestring
messagesIDocumentMessage[][]

initialize

Signature

protected initialize(connectMessage: IConnect, timeout: number): Promise<void>;

Parameters

ParameterTypeDescription
connectMessageIConnect
timeoutnumber

Returns

Return type: Promise<void>

submit

Submits a new delta operation to the server

Signature

submit(messages: IDocumentMessage[]): void;

Parameters

ParameterTypeDescription
messagesIDocumentMessage[]

submitCore

Signature

protected submitCore(type: string, messages: IDocumentMessage[]): void;

Parameters

ParameterTypeDescription
typestring
messagesIDocumentMessage[]

submitSignal

Submits a new signal to the server

Signature

submitSignal(message: IDocumentMessage): void;

Parameters

ParameterTypeDescription
messageIDocumentMessagesignal to submit