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

x/sockets/mod.ts>Channel

A WebSocket library for Deno.
Latest
class Channel
import { Channel } from "https://deno.land/x/sockets@v0.5.0/mod.ts";

Channel represents channels, also known as "rooms". This class describes open channels, and is used to place clients into

Constructors

new
Channel(name: string)

Construct an object of this class.

Properties

callbacks: Function[]

The callbacks for listening

function handleChannel1 (...) { ... }
socketServer.on("channel 1", handleChannel1)

handleChannel1 is now registered as a callback.

listeners: Map<number, WebSocket>

Acts as the list of clients connected to the channel. A listener would contain the clients socket id and and the socket connection sent across

new Channel("channel 1").listeners.set(
  2, // clients socket id
  incomingSocketConnection
})
name: string

The name of the channel to create

new Channel("channel 1");