Skip to main content
class Sono
import { Sono } from "https://deno.land/x/sono@v1.1/src/server.ts";

Class that handles WebSocket messages. Uses Client objects and an EventHandler object to send messages to Clients.

Constructors

new
Sono()

Constructor creates a new instance of the Event, binds handleWs to this and returns a Sono instance.

Properties

channelsList: { [key: string]: Record<string, Client>; }
clients: { [key: string]: Client; }
eventHandler: EventHandler
hostname: string
lastClientId: number
server: DenoServer | null

Methods

channel(name: string, callback: () => void): void

Adding a channel to channelsList object

connect(req: ServerRequest, callback: () => void)
emit(message: string)
handleWs(socket: WebSocket): Promise<void>

handleWS method handles a socket connection Instantiants a new client Events of socket are looped thru and dealt with accordingly