Skip to main content

core.iwebsocket

Home > @medplum/core > IWebSocket

IWebSocket interface

Generic interface that an implementation of WebSocket must satisfy to be used with ReconnectingWebSocket. This is a slightly modified fork of the WebSocket global type used in Node.

The main key difference is making all the onclose, onerror, etc. functions have any[] args, making data in send() of type any, and making binaryType of type string, though the particular implementation should narrow each of these implementation-specific types.

Signature:

export interface IWebSocket 

Properties

Property

Modifiers

Type

Description

binaryType

string

bufferedAmount

readonly

number

CLOSED

readonly

number

CLOSING

readonly

number

CONNECTING

readonly

number

extensions

readonly

string

onclose

((...args: any[]) => any) | null

onerror

((...args: any[]) => any) | null

onmessage

((...args: any[]) => any) | null

onopen

((...args: any[]) => any) | null

OPEN

readonly

number

protocol

readonly

string

readyState

readonly

number

url

readonly

string

Methods

Method

Description

addEventListener(type, listener, options)

addEventListener(type, listener, options)

close(code, reason)

removeEventListener(type, listener, options)

removeEventListener(type, listener, options)

send(data)