Skip to main content
Deno 2 is finally here 🎉️
Learn more
Latest
class WebSocketClient
extends WebSocket
import { WebSocketClient } from "https://deno.land/x/wocket@v1.0.0/src/websocket_client.ts";

A helper class built on top of the native WebSocket, to make it easier to send messages to channels, and listen for messages on channels.

Specifically built for Drash.

Only defined an onmessage handler.

Constructors

new
WebSocketClient(url: string)

Methods

on<T extends Record<string, unknown>>(channelName: string, cb: (message: T) => void)

Register a listener for a channel name

to(channelName: string, message: Record<string, unknown> | string | Uint8Array): void

Send a message to the server