Skip to content

Commit 8edb356

Browse files
committed
ok
1 parent 98b8386 commit 8edb356

File tree

1 file changed

+0
-27
lines changed

1 file changed

+0
-27
lines changed

src/content/docs/agents/api-reference/agents-api.mdx

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -247,33 +247,6 @@ interface ConnectionContext {
247247
}
248248
```
249249

250-
<TypeScriptExample>
251-
252-
```ts
253-
// Example of authenticating connections during connect
254-
async onConnect(connection: Connection, ctx: ConnectionContext) {
255-
// Access request information from the connection context
256-
const url = new URL(ctx.request.url);
257-
const token = url.searchParams.get('token');
258-
259-
// Validate the token
260-
if (!token || !await this.isValidToken(token)) {
261-
// Reject invalid connections
262-
connection.close(1008, 'Unauthorized');
263-
return;
264-
}
265-
266-
// Store user info in connection state
267-
const userId = await this.getUserIdFromToken(token);
268-
connection.setState({ userId, authenticated: true });
269-
270-
// Inform user they're connected
271-
connection.send(JSON.stringify({ type: 'connected', userId }));
272-
}
273-
```
274-
275-
</TypeScriptExample>
276-
277250
### State synchronization API
278251

279252
:::note

0 commit comments

Comments
 (0)