bdcontract-sdk-javascript/types/wssocket.d.ts
2023-03-15 01:15:57 +08:00

27 lines
749 B
TypeScript

export interface WsEvent {
data: string;
}
export type OnOpenHandler = (this: WebSocket, ev: Event) => void;
export type WsHandler = (ev: WsEvent, ws?: WebSocket) => void;
interface SegmentData {
action: 'sendSeg';
cid: string;
data: string;
}
export declare class WsSocket {
private handlerList;
private toSend;
private isSending;
private sendList;
private toReceive;
private wssocket;
constructor(wsurl: string, onopen: OnOpenHandler, handler?: WsHandler);
status(): WebSocket['CLOSED' | 'CLOSING' | 'CONNECTING' | 'OPEN'];
sendNextSegment(): void;
receiveSeg(obj: SegmentData): void;
monitor(): void;
send(data: string): void;
addHandler(handler: WsHandler): void;
}
export {};