Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/socket_io/mod.ts>Server#to

Socket.IO server for Deno
Latest
method Server.prototype.to
import { Server } from "https://deno.land/x/socket_io@0.2.0/mod.ts";

Targets a room when emitting.

Examples

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

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

// with multiple chained calls io.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