constants.js 621 Bytes
/** WebSocket 连接状态 */
export const SocketState = {
  IDLE: 'idle',
  CONNECTING: 'connecting',
  OPEN: 'open',
  CLOSING: 'closing',
  CLOSED: 'closed'
}

export const DEFAULT_OPTIONS = {
  /** 断线后是否自动重连 */
  reconnect: true,
  /** 重连间隔(ms) */
  reconnectInterval: 3000,
  /** 最大重连次数,-1 表示不限 */
  reconnectMaxRetries: -1,
  /** 未连接时是否缓存 send 队列 */
  enableSendQueue: true,
  /** send 队列上限 */
  sendQueueMax: 100,
  /** 收到文本消息时尝试 JSON.parse */
  autoParseJson: true,
  /** 日志标签 */
  logTag: 'SocketClient'
}