18 lines
835 B
TypeScript
18 lines
835 B
TypeScript
import { TinyEmitter } from "tiny-emitter"
|
|
|
|
export type Bytes = Uint8Array
|
|
export type OnMessage = (message: Object) => any
|
|
|
|
export type ConnectionState = "none" | "connecting" | "error" | "connected" | "closed" | "reconnecting";
|
|
|
|
export type RtmtEventTypes = "open" | "close" | "connected" | "error" | "disconnected" | "message" | "connectionchange";
|
|
|
|
export interface RTMT extends TinyEmitter {
|
|
get connectionState(): ConnectionState;
|
|
sendMessage: (channel: string, message: Object) => void;
|
|
addMessageListener(channel: string, callback: (message: any) => void): any;
|
|
removeMessageListener(channel: string, callback: (message: any) => void): any;
|
|
on(event: RtmtEventTypes, callback: (...value: any[]) => void): this;
|
|
off(event: RtmtEventTypes, callback: (...value: any[]) => void): this;
|
|
dispose(): any;
|
|
} |