Skip to content
Meeko
Type to search the guides and the API reference. Open it from any page with / or Ctrl K; move with the arrow keys and open a result with Enter.
Get started

Contents

On this page

Not translated yet

This page has not been translated into English yet, so it is shown in Spanish.

SocketUpgrade

tipo

Resultado de la comprobación de política que precede al upgrade del transporte.

ts
import type { SocketUpgrade } from "@meekojs/meeko/server";

Source code src/server/runtime/upgrade.ts:65

Declaración #

ts
type SocketUpgrade =
| {
		readonly action: 'pass'
  }
| {
		readonly action: 'reject'
		readonly status: number
		readonly close?: { readonly code: 4401 | 4403; readonly reason: string }
  }
| {
		readonly action: 'upgrade'
		readonly channel: string
		readonly roomId: string | undefined
		readonly request: Request
		open(peer: SocketPeer): SocketSession
  }

Example #

ts
const upgrade = await handleUpgrade(request);
if (upgrade.action === "pass") return app.fetch(request);
if (upgrade.action === "reject" && upgrade.close) {
  // Rechazo de autenticación o autorización: acepta el WebSocket y lo cierra con upgrade.close.code.
}
if (upgrade.action === "reject") return new Response(null, { status: upgrade.status });
// upgrade.action === "upgrade": el adaptador acepta el WebSocket y llama a upgrade.open(peer).

See also #

Was this page helpful?

Add a comment

It is sent when you choose “Yes” or “No”. Only the page, your answer and the comment are stored: no cookies and no personal data.

0 of 2000 characters

Edit on GitHub: packages/meeko/src/server/runtime/upgrade.ts