Skip to content

@fkn/lib/websocket

The platform’s WebSocket, opened by FKN’s proxy on the node the session uses: the server sees that node’s address, never the person’s, and the proxy applies its egress validation, fair-use limits and metering as for a fetch. Its messages pass through the proxy’s memory, so it is for servers the browser should not reach from its own address.

It behaves as the platform’s, events and their order included, with what the platform also refuses: a url that is not ws:, wss:, http: or https:, a fragment, a protocol that is not a token or is offered twice. It also refuses FKN’s own hosts and a protocol named fkn-proxy or starting fkn-proxy., which carry the target to the proxy. Nothing reconnects by itself. A Worker needs relayWorker from its page first; without it the socket fails once the broker has not answered within the deadline of apiWithin. extensions is always empty.

  • EventTarget
new WebSocket(url, protocols?): WebSocket;

string | URL

string | string[]

WebSocket

EventTarget.constructor
readonly CLOSED: 3;
readonly CLOSING: 2;
readonly CONNECTING: 0;
readonly extensions: "" = '';
readonly OPEN: 1;
readonly url: string;
readonly static CLOSED: 3;
readonly static CLOSING: 2;
readonly static CONNECTING: 0;
readonly static OPEN: 1;
get binaryType(): BinaryType;

BinaryType

set binaryType(type): void;

BinaryType

void

get bufferedAmount(): number;

number

get onclose(): Handler<CloseEvent>;

Handler<CloseEvent>

set onclose(handler): void;

Handler<CloseEvent>

void

get onerror(): Handler<Event>;

Handler<Event>

set onerror(handler): void;

Handler<Event>

void

get onmessage(): Handler<MessageEvent<any>>;

Handler<MessageEvent<any>>

set onmessage(handler): void;

Handler<MessageEvent<any>>

void

get onopen(): Handler<Event>;

Handler<Event>

set onopen(handler): void;

Handler<Event>

void

get protocol(): string;

string

get readyState(): 0 | 1 | 2 | 3;

0 | 1 | 2 | 3

addEventListener<K>(
type,
listener,
options?): void;

K extends keyof WebSocketEventMap

K

(this, ev) => any

boolean | AddEventListenerOptions

void

EventTarget.addEventListener
addEventListener(
type,
listener,
options?): void;

string

EventListenerOrEventListenerObject

boolean | AddEventListenerOptions

void

EventTarget.addEventListener
close(code?, reason?): void;

number

string

void

removeEventListener<K>(
type,
listener,
options?): void;

K extends keyof WebSocketEventMap

K

(this, ev) => any

boolean | EventListenerOptions

void

EventTarget.removeEventListener
removeEventListener(
type,
listener,
options?): void;

string

EventListenerOrEventListenerObject

boolean | EventListenerOptions

void

EventTarget.removeEventListener
send(data): void;

string | Blob | ArrayBufferLike | ArrayBufferView<ArrayBufferLike>

void