Function initWebSocket

  • 初始化 websocket

    Parameters

    • options: {
          onClose?: any;
          onError?: any;
          onMessage?: any;
          onOpen?: any;
          reconnect?: {
              delay?: number;
              onReconnect?: any;
              times: number;
          };
          timeout?: number;
          url: string;
      }

      {url, onOpen, onMessage, onClose, onError, timeout, reconnect: {times, delay, onReconnect} | boolean} WebSocket 配置

      • OptionalonClose?: any
      • OptionalonError?: any
      • OptionalonMessage?: any
      • OptionalonOpen?: any
      • Optionalreconnect?: {
            delay?: number;
            onReconnect?: any;
            times: number;
        }
        • Optionaldelay?: number
        • OptionalonReconnect?: any
        • times: number
      • Optionaltimeout?: number
      • url: string

    Returns WebSocket

    initWebSocket({ url: 'ws://localhost:8080/ws', timeout: 30000, onOpen: () => {}, onMessage: () => {}, onClose: () => {}, onError: () => {}, reconnect: {} })