Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Latest
method Namespace.prototype.to
import { Namespace } from "https://deno.land/x/socket_io@0.2.0/packages/socket.io/lib/namespace.ts";

Targets a room when emitting.

Examples

const myNamespace = io.of("/my-namespace");

// the “foo” event will be broadcast to all connected clients in the “room-101” room myNamespace.to("room-101").emit("foo", "bar");

// with an array of rooms (a client will be notified at most once) myNamespace.to(["room-101", "room-102"]).emit("foo", "bar");

// with multiple chained calls myNamespace.to("room-101").to("room-102").emit("foo", "bar");

Parameters

room: Room | Room[]
  • a room, or an array of rooms

Returns

BroadcastOperator<EmitEvents, SocketData>

a new BroadcastOperator instance for chaining