@gladiaio/sdk
Version:
Gladia JavaScript/TypeScript SDK
38 lines • 1.18 kB
TypeScript
//#region src/network/iso-ws.d.ts
declare const WS_STATES: {
readonly CONNECTING: 0;
readonly OPEN: 1;
readonly CLOSING: 2;
readonly CLOSED: 3;
};
type ErrorEvent = Error;
type CloseEvent = {
/**
* Returns the WebSocket connection close code provided by the server.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/code)
*/
readonly code: number;
/**
* Returns the WebSocket connection close reason provided by the server.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/reason)
*/
readonly reason: string;
};
type MessageEvent = {
data: string | ArrayBuffer;
};
interface IsoWS {
readonly url: string;
readonly readyState: typeof WS_STATES.CONNECTING | typeof WS_STATES.OPEN | typeof WS_STATES.CLOSING | typeof WS_STATES.CLOSED;
onopen: (() => void) | null;
onerror: ((error: ErrorEvent) => void) | null;
onclose: ((event: CloseEvent) => void) | null;
onmessage: ((event: MessageEvent) => void) | null;
send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;
close(code: number): void;
}
//#endregion
export { IsoWS, WS_STATES };
//# sourceMappingURL=iso-ws.d.ts.map