mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2026-01-27 17:37:18 +01:00
733 B
733 B
WebSocket API for QuickJS
Introduction
This is an implementation of the W3C WebSocket API for the QuickJS JavaScript engine on top of the libwebsockets C library.
Usage
import { WebSocket } from '/usr/lib/quickjs/websocket.js'
const w = new WebSocket('wss://example.com/', ['protocol1', 'protocol2'])
globalThis.WebSocket = WebSocket // To make the API available globally
Limitations
Events emitted by WebSocket objects do not implement the full DOM event specification. Only a subset of properties is available. The EventTarget interface, i.e. addEventListener/removeEventListener, is unimplemented. The onopen/onerror/onclose/onmesseage handlers have to be used instead.