1 | export declare enum ReadyState {
|
2 | Connecting = 0,
|
3 | Open = 1,
|
4 | Closing = 2,
|
5 | Closed = 3
|
6 | }
|
7 | export interface Options {
|
8 | reconnectLimit?: number;
|
9 | reconnectInterval?: number;
|
10 | manual?: boolean;
|
11 | onOpen?: (event: WebSocketEventMap['open'], instance: WebSocket) => void;
|
12 | onClose?: (event: WebSocketEventMap['close'], instance: WebSocket) => void;
|
13 | onMessage?: (message: WebSocketEventMap['message'], instance: WebSocket) => void;
|
14 | onError?: (event: WebSocketEventMap['error'], instance: WebSocket) => void;
|
15 | protocols?: string | string[];
|
16 | }
|
17 | export interface Result {
|
18 | latestMessage?: WebSocketEventMap['message'];
|
19 | sendMessage: WebSocket['send'];
|
20 | disconnect: () => void;
|
21 | connect: () => void;
|
22 | readyState: ReadyState;
|
23 | webSocketIns?: WebSocket;
|
24 | }
|
25 | export default function useWebSocket(socketUrl: string, options?: Options): Result;
|