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

x/ayonli_jsext/ws.ts

A JavaScript extension package for building strong and modern applications.
Latest
import * as ayonliJsext from "https://deno.land/x/ayonli_jsext@v0.9.72/ws.ts";

This module provides a unified WebSocket server interface for Node.js, Deno, Bun and Cloudflare Workers. This module is based on the EventTarget interface and conforms the web standard.

IMPORTANT: The WebSocketConnection interface is an abstraction of the WebSocket on the server side, it's design is not consistent with the WebSocket API in the browser. For example, when receiving binary data, the data property is always a Uint8Array object, which is different from the Blob object (or ArrayBuffer) in the browser. In the future, we may provide a more consistent API, be aware of this when using this module.

Classes

This class represents a WebSocket connection on the server side. Normally we don't create instances of this class directly, but rather use the WebSocketServer to handle WebSocket connections, which will create the instance for us.

A unified WebSocket server interface for Node.js, Deno, Bun and Cloudflare Workers.

Interfaces

Options for the WebSocketServer constructor.

Type Aliases

WebSocket handler function for the WebSocketServer constructor.