Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

WebSocketLike.md

108 lines1.5 KB

1---
2id: WebSocketLike
3title: WebSocketLike
4---
5​
6Defined in: [packages/ai/src/stream-to-websocket.ts:15](https://github.com/TanStack/ai/blob/main/packages/ai/src/stream-to-websocket.ts#L15)
7​
8The minimal WHATWG WebSocket surface the core needs. Cloudflare
9`WebSocketPair` server sockets, Deno's upgraded sockets, and `ws` (Node)
10sockets already satisfy it; Bun's `ServerWebSocket` (handler-object API)
11gets a ~10-line adapter at the call site.
12​
13## Properties
14​
15### addEventListener
16​
17```ts
18addEventListener: {
19 (type, handler): void;
20 (type, handler): void;
21};
22```
23​
24Defined in: [packages/ai/src/stream-to-websocket.ts:18](https://github.com/TanStack/ai/blob/main/packages/ai/src/stream-to-websocket.ts#L18)
25​
26#### Call Signature
27​
28```ts
29(type, handler): void;
30```
31​
32##### Parameters
33​
34###### type
35​
36`"message"`
37​
38###### handler
39​
40(`ev`) => `void`
41​
42##### Returns
43​
44`void`
45​
46#### Call Signature
47​
48```ts
49(type, handler): void;
50```
51​
52##### Parameters
53​
54###### type
55​
56`"error"` \| `"close"`
57​
58###### handler
59​
60() => `void`
61​
62##### Returns
63​
64`void`
65​
66***
67​
68### close
69​
70```ts
71close: (code?, reason?) => void;
72```
73​
74Defined in: [packages/ai/src/stream-to-websocket.ts:17](https://github.com/TanStack/ai/blob/main/packages/ai/src/stream-to-websocket.ts#L17)
75​
76#### Parameters
77​
78##### code?
79​
80`number`
81​
82##### reason?
83​
84`string`
85​
86#### Returns
87​
88`void`
89​
90***
91​
92### send
93​
94```ts
95send: (data) => void;
96```
97​
98Defined in: [packages/ai/src/stream-to-websocket.ts:16](https://github.com/TanStack/ai/blob/main/packages/ai/src/stream-to-websocket.ts#L16)
99​
100#### Parameters
101​
102##### data
103​
104`string`
105​
106#### Returns
107​
108`void`