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>

Source ​

realtime/types.ts:30


disconnect() ​

disconnect(): void

Returns ​

void

Source ​

realtime/types.ts:31


onWebSocket() ​

onWebSocket(event, callback) ​

onWebSocket(event, callback): RemoveEventHandler

Parameters ​

• event: "open"

• callback

Returns ​

RemoveEventHandler

Source ​

realtime/types.ts:32

onWebSocket(event, callback) ​

onWebSocket(event, callback): RemoveEventHandler

Parameters ​

• event: "error"

• callback

Returns ​

RemoveEventHandler

Source ​

realtime/types.ts:33

onWebSocket(event, callback) ​

onWebSocket(event, callback): RemoveEventHandler

Parameters ​

• event: "close"

• callback

Returns ​

RemoveEventHandler

Source ​

realtime/types.ts:34

onWebSocket(event, callback) ​

onWebSocket(event, callback): RemoveEventHandler

Parameters ​

• event: "message"

• callback

Returns ​

RemoveEventHandler

Source ​

realtime/types.ts:35

onWebSocket(event, callback) ​

onWebSocket(event, callback): RemoveEventHandler

Parameters ​

• event: WebSocketEvents

• callback: WebSocketEventHandler

Returns ​

RemoveEventHandler

Source ​

realtime/types.ts:36


sendMessage() ​

sendMessage(message): void

Parameters ​

• message: string | Record<string, any>

Returns ​

void

Source ​

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>, Merge<MappedFunctionFields<Schema, UnpackList<IfAny<..., ..., ...>>> extends FF ? MapFlatFields<UnpackList<IfAny<..., ..., ...>>, FieldsWildcard<UnpackList<...>, Exclude<..., ...>>, FF extends Record<..., ...> ? FF<...> : Record<..., ...>> : never, PickRelationalFields<UnpackList<Mutable<...>>> extends never ? never : { [Field in string | number | symbol]: Field extends keyof (...) ? (...) extends (...) ? (...) : (...) : never }>> : Partial<Schema[Collection]>>, void, unknown>

unsubscribe() ​
Returns ​

void

Source ​

realtime/types.ts:38