Skip to content
On this page

Directus Cloud

Everything you need to start building. Provisioned in 90 seconds. Starting at $15/month.

Get Started

This is an auto-generated document to support extension builders understand the internal packages they can utilize. To find our written guides, tutorials, and API/SDK reference, check out our main docs .

Directus / @directus/sdk / realtime / WebSocketClient

Interface: WebSocketClient<Schema> ​

Type Parameters ​

• Schema

Methods ​

connect() ​

connect(): Promise<WebSocketInterface>

Returns ​

Promise<WebSocketInterface>

Defined in ​

realtime/types.ts:30


disconnect() ​

disconnect(): void

Returns ​

void

Defined in ​

realtime/types.ts:31


onWebSocket() ​

onWebSocket(event, callback) ​

onWebSocket(event, callback): RemoveEventHandler

Parameters ​

• event: "open"

• callback

Returns ​

RemoveEventHandler

Defined in ​

realtime/types.ts:32

onWebSocket(event, callback) ​

onWebSocket(event, callback): RemoveEventHandler

Parameters ​

• event: "error"

• callback

Returns ​

RemoveEventHandler

Defined in ​

realtime/types.ts:33

onWebSocket(event, callback) ​

onWebSocket(event, callback): RemoveEventHandler

Parameters ​

• event: "close"

• callback

Returns ​

RemoveEventHandler

Defined in ​

realtime/types.ts:34

onWebSocket(event, callback) ​

onWebSocket(event, callback): RemoveEventHandler

Parameters ​

• event: "message"

• callback

Returns ​

RemoveEventHandler

Defined in ​

realtime/types.ts:35

onWebSocket(event, callback) ​

onWebSocket(event, callback): RemoveEventHandler

Parameters ​

• event: WebSocketEvents

• callback: WebSocketEventHandler

Returns ​

RemoveEventHandler

Defined in ​

realtime/types.ts:36


sendMessage() ​

sendMessage(message): void

Parameters ​

• message: string | Record<string, any>

Returns ​

void

Defined in ​

realtime/types.ts:37


subscribe() ​

subscribe<Collection, Options>(collection, options?): Promise<object>

Type Parameters ​

• Collection extends string | number | symbol

• Options extends SubscribeOptions<Schema, Collection>

Parameters ​

• collection: Collection

• options?: Options

Returns ​

Promise<object>

subscription ​

subscription: AsyncGenerator<SubscriptionOutput<Schema, Collection, Options["query"], Fallback<Options["event"], SubscriptionOptionsEvents> | "init", Options["query"] extends Query<Schema, Schema[Collection]> ? IfAny<Schema, Record<string, any>, { [K in string | number | symbol]: Merge<MappedFunctionFields<(...), (...)> extends FF ? MapFlatFields<(...), (...), (...)> : never, PickRelationalFields<(...)> extends never ? never : { [Field in (...)]: (...) }>[K] }> : Partial<Schema[Collection]>>, void, unknown>

unsubscribe() ​
Returns ​

void

Defined in ​

realtime/types.ts:38