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

Class with static methods that handles messages from WebSocket connections.

Constructors

new
EventHandler()

Methods

broadcast(
packet: Packet,
client: Client,
channelsList: { [key: string]: Record<string, Client>; },
)

Broadcast data to all clients except for the cliet sending the data

changeChannel(
packet: Packet,
client: Client,
channelsList: { [key: string]: Record<string, Client>; },
): { [key: string]: Record<string, Client>; }

Changes the channel client is in

directMessage(
packet: Packet,
client: Client,
clients: { [key: string]: Client; },
)

Direct messages to a specific client

grab(
packet: Packet,
client: Client,
clients: { [key: string]: Client; },
channelsList: { [key: string]: Record<string, Client>; },
)

Provides the list of clients that are connected to the server

handleMessage(
packet: Packet,
client: Client,
channelsList: { [key: string]: Record<string, Client>; },
)

Sends a message to each Client object in the same channel as client