Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/wocket/src/server.ts>Server#broadcast

A WebSocket library for Deno
Latest
method Server.prototype.broadcast
import { Server } from "https://deno.land/x/wocket@v1.0.0/src/server.ts";

Broadcast to other clients in a channel excluding the one passed in

Examples

Example 1

interface SomeEvent { id: number }
server.on("some-event", (event: CustomEvent<SomeEvent>) => {
  const { id } = event.detail
  server.broadcast("some-channel", {
    message: "Shh everybody! " + id + " won't be getting this message!"
  }, id)
})

Parameters

channelName: string
  • Channel to send the message to
message: Record<string, unknown>
  • The message to send
id: number
  • Id of client it ignore (not send the message to)