Skip to content
On this page

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 extends object

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: (this, ev) => any

Returns

RemoveEventHandler

Source

realtime/types.ts:32

onWebSocket(event, callback)

onWebSocket(event, callback): RemoveEventHandler

Parameters

event: "error"

callback: (this, ev) => any

Returns

RemoveEventHandler

Source

realtime/types.ts:33

onWebSocket(event, callback)

onWebSocket(event, callback): RemoveEventHandler

Parameters

event: "close"

callback: (this, ev) => any

Returns

RemoveEventHandler

Source

realtime/types.ts:34

onWebSocket(event, callback)

onWebSocket(event, callback): RemoveEventHandler

Parameters

event: "message"

callback: (this, ev) => any

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<Schema, any, Collection extends keyof Schema ? UnpackList<Schema[Collection]> extends object ? object & UnpackList<Schema[Collection]> : never : never>>> extends FF ? MapFlatFields<UnpackList<IfAny<Schema, any, Collection extends keyof Schema ? UnpackList<Schema[Collection]> extends object ? object & UnpackList<Schema[Collection]> : never : never>>, FieldsWildcard<UnpackList<IfAny<Schema, any, Collection extends keyof Schema ? UnpackList<Schema[Collection]> extends object ? object & UnpackList<Schema[Collection]> : never : never>>, Exclude<UnpackList<Mutable<any[any]["fields"]>>, PickRelationalFields<UnpackList<Mutable<any[any]["fields"]>>> extends never ? never : AllKeys<UnpackList<UnpackList<Mutable<any[any]["fields"]>>> extends Field ? Field extends object ? Field : never : never>>>, FF extends Record<string, string> ? FF : Record<string, string>> : never, PickRelationalFields<UnpackList<Mutable<any[any]["fields"]>>> extends never ? never : { [Field in string | number | symbol]: Field extends keyof UnpackList<IfAny<Schema, any, Collection extends keyof Schema ? UnpackList<Schema[Collection]> extends object ? object & UnpackList<Schema[Collection]> : never : never>> ? Extract<UnpackList<IfAny<Schema, any, Collection extends keyof Schema ? UnpackList<Schema[Collection]> extends object ? object & UnpackList<Schema[Collection]> : never : never>>[Field], ItemType<Schema>> extends RelatedCollection ? IsNullable<UnpackList<IfAny<Schema, any, Collection extends keyof Schema ? UnpackList<Schema[Collection]> extends object ? object & UnpackList<Schema[Collection]> : never : never>>[Field], null | (RelatedCollection extends any[] ? HasManyToAnyRelation<RelatedCollection> extends never ? null | ApplyNestedQueryFields<Schema, RelatedCollection, PickRelationalFields<UnpackList<Mutable<any[any]["fields"]>>>[Field]>[] : ApplyManyToAnyFields<Schema, RelatedCollection, PickRelationalFields<UnpackList<Mutable<any[any]["fields"]>>>[Field], UnpackList<RelatedCollection>>[] : ApplyNestedQueryFields<Schema, RelatedCollection, PickRelationalFields<UnpackList<Mutable<any[any]["fields"]>>>[Field]>), RelatedCollection extends any[] ? HasManyToAnyRelation<RelatedCollection> extends never ? null | ApplyNestedQueryFields<Schema, RelatedCollection, PickRelationalFields<UnpackList<Mutable<any[any]["fields"]>>>[Field]>[] : ApplyManyToAnyFields<Schema, RelatedCollection, PickRelationalFields<UnpackList<Mutable<any[any]["fields"]>>>[Field], UnpackList<RelatedCollection>>[] : ApplyNestedQueryFields<Schema, RelatedCollection, PickRelationalFields<UnpackList<Mutable<any[any]["fields"]>>>[Field]>> : never : never }>> : Partial<Schema[Collection]>>, void, unknown>

unsubscribe()
Returns

void

Source

realtime/types.ts:38