mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
23 lines
733 B
Text
Executable file
23 lines
733 B
Text
Executable file
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.
|