iopsys-feed/quickjs-websocket
2021-12-01 16:22:58 +01:00
..
src quickjs-websocket: 1.1 2021-12-01 16:22:58 +01:00
Makefile quickjs-websocket: 1.1 2021-12-01 16:22:58 +01:00
README quickjs-websocket: 1.1 2021-12-01 16:22:58 +01:00

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.