minigame-std
    Preparing search index...

    Interface SocketOptions

    创建Socket的可选参数。

    1.0.0

    import { connectSocket, type SocketOptions } from 'minigame-std';

    const options: SocketOptions = {
    protocols: ['protocol1', 'protocol2'],
    headers: { 'Authorization': 'Bearer token' },
    };
    const socket = connectSocket('wss://example.com', options);
    interface SocketOptions {
        forceCellularNetwork?: boolean;
        headers?: Record<string, string>;
        perMessageDeflate?: boolean;
        protocols?: string[];
        tcpNoDelay?: boolean;
        timeout?: number;
    }

    Hierarchy

    • Omit<
          WechatMinigame.ConnectSocketOption,
          "url"
          | "header"
          | "complete"
          | "success"
          | "fail",
      >
      • SocketOptions
    Index

    Properties

    forceCellularNetwork?: boolean

    需要基础库: 2.29.0

    强制使用蜂窝网络发送请求

    headers?: Record<string, string>
    perMessageDeflate?: boolean

    需要基础库: 2.8.0

    是否开启压缩扩展

    protocols?: string[]

    需要基础库: 1.4.0

    子协议数组

    tcpNoDelay?: boolean

    需要基础库: 2.4.0

    建立 TCP 连接的时候的 TCP_NODELAY 设置

    timeout?: number

    需要基础库: 2.10.0

    超时时间,单位为毫秒