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.

SocketContract

interfaz

Contrato público de un canal Socket: los schemas de cada evento en cada dirección. Meeko lo genera a partir de defineSocketChannel sin importar los handlers privados.

ts
import type { SocketContract } from "@meekojs/meeko/framework";

Source code src/app/runtime/socket.ts:52

Declaración #

ts
interface SocketContract<ClientToServer extends Events = Events, ServerToClient extends Events = Events> {
	readonly clientToServer: ClientToServer
	readonly serverToClient: ServerToClient
}

Type parameters #

ClientToServer extends Events = Events
ServerToClient extends Events = Events

Example #

ts
import * as v from "valibot";
import type { SocketContract } from "@meekojs/meeko/framework";

const chat = {
  clientToServer: { message: v.object({ text: v.string(), roomId: v.string() }) },
  serverToClient: { message: v.object({ text: v.string() }) },
} satisfies SocketContract;

Propiedades #

clientToServer #

propiedad sólo lectura

readonly clientToServer: ClientToServer

Eventos que envía el cliente, con su schema.

serverToClient #

propiedad sólo lectura

readonly serverToClient: ServerToClient

Eventos que envía el servidor, con su schema.

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