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.

SocketPubSub

interfaz

Broker entre hubs. publish se resuelve cuando el broker acepta el mensaje; la entrega a cada peer suscrito ocurre como mucho una vez y sus fallos nunca llegan al emisor. subscribe se resuelve cuando el broker ya escucha. Los listeners del hub nunca rechazan.

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

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

Declaración #

ts
interface SocketPubSub {
	publish(channel: string, room: string, message: SocketMessage): Promise<void>
	subscribe(channel: string, room: string, listener: (message: SocketMessage) => void | Promise<void>): Unsubscribe | Promise<Unsubscribe>
}

Example #

ts
import type { SocketMessage, SocketPubSub } from "@meekojs/meeko/server";

class LoggingPubSub implements SocketPubSub {
  constructor(private readonly inner: SocketPubSub) {}
  async publish(channel: string, room: string, message: SocketMessage): Promise<void> {
    console.info("publish", channel, room, message.event);
    await this.inner.publish(channel, room, message);
  }
  subscribe(channel: string, room: string, listener: (message: SocketMessage) => void | Promise<void>) {
    return this.inner.subscribe(channel, room, listener);
  }
}

Miembros #

publish #

método

publish(channel: string, room: string, message: SocketMessage): Promise<void>

Publica un mensaje en el par canal/sala; se resuelve cuando el broker lo acepta.

subscribe #

método

subscribe(channel: string, room: string, listener: (message: SocketMessage) => void | Promise<void>): Unsubscribe | Promise<Unsubscribe>

Escucha el par canal/sala; se resuelve cuando el broker ya escucha.

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