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.

SocketConnection

interfaz

Conexión aceptada por el hub, que el adaptador alimenta con los mensajes del peer.

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

Source code src/server/socket/runtime.ts:190

Declaración #

ts
interface SocketConnection {
	receive(message: string | Uint8Array): Promise<void>
	emit(event: string, payload: unknown): Promise<void>
	close(code?: number, reason?: string): void
}

Example #

ts
const connection = await hub.accept("chat", request, peerOf(socket), "general");
socket.addEventListener("message", (event) => void connection.receive(event.data as string));
socket.addEventListener("close", () => connection.close());

Miembros #

receive #

método

receive(message: string | Uint8Array): Promise<void>

Procesa un mensaje del cliente en JSON (texto o bytes UTF-8); uno demasiado grande cierra con 1009 y uno inválido con 1008.

emit #

método

emit(event: string, payload: unknown): Promise<void>

Valida y envía un evento del servidor a este peer.

close #

método

close(code?: number, reason?: string): void

Cierra la conexión y la desuscribe de su sala.

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/socket/runtime.ts