File tree Expand file tree Collapse file tree 1 file changed +0
-27
lines changed
src/content/docs/agents/api-reference Expand file tree Collapse file tree 1 file changed +0
-27
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments