import EventEmitter2, { Listener } from "eventemitter2"

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 EventEmitter2 {
    get connectionState() : ConnectionState;
    sendMessage: (channel: string, message: Object) => void;
    addMessageListener(channel: string, callback: (message: any) => void);
    removeMessageListener(channel: string, callback: (message: any) => void);
    on(event: RtmtEventTypes, callback: (...value: any[]) => void): Listener | this;
    off(event: RtmtEventTypes, callback: (...value: any[]) => void): this;
    dispose();
}