mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
46 lines
1.0 KiB
TypeScript
46 lines
1.0 KiB
TypeScript
import ReconnectingWebSocket, { Options } from "reconnectingwebsocket";
|
|
|
|
const options: Options = {
|
|
automaticOpen: false,
|
|
binaryType: "blob",
|
|
debug: false,
|
|
maxReconnectAttempts: 1,
|
|
maxReconnectInterval: 1000,
|
|
reconnectDecay: 1.5,
|
|
reconnectInterval: 1000,
|
|
timeoutInterval: 1000
|
|
};
|
|
|
|
const ws1: ReconnectingWebSocket = new ReconnectingWebSocket("url", ["protocol"], options);
|
|
const ws2: ReconnectingWebSocket = new ReconnectingWebSocket("url", ["protocol"]);
|
|
const ws3: ReconnectingWebSocket = new ReconnectingWebSocket("url");
|
|
|
|
ReconnectingWebSocket.debugAll = true;
|
|
ReconnectingWebSocket.CONNECTING = WebSocket.CONNECTING;
|
|
ReconnectingWebSocket.OPEN = WebSocket.OPEN;
|
|
ReconnectingWebSocket.CLOSING = WebSocket.CLOSING;
|
|
ReconnectingWebSocket.CLOSED = WebSocket.CLOSED;
|
|
|
|
ws1.onclose = (event: any) => {
|
|
};
|
|
|
|
ws2.onconnecting = (event: any) => {
|
|
};
|
|
|
|
ws3.onerror = (event: any) => {
|
|
};
|
|
|
|
ws1.onmessage = (event: any) => {
|
|
};
|
|
|
|
ws1.onopen = (event: any) => {
|
|
};
|
|
|
|
ws1.open(true);
|
|
|
|
ws1.refresh();
|
|
|
|
ws1.send({});
|
|
|
|
ws1.close();
|