11e934351Sopenharmony_ci/*
21e934351Sopenharmony_ci * Copyright (c) 2022-2024 Huawei Device Co., Ltd.
31e934351Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
41e934351Sopenharmony_ci * you may not use this file except in compliance with the License.
51e934351Sopenharmony_ci * You may obtain a copy of the License at
61e934351Sopenharmony_ci *
71e934351Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
81e934351Sopenharmony_ci *
91e934351Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
101e934351Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
111e934351Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
121e934351Sopenharmony_ci * See the License for the specific language governing permissions and
131e934351Sopenharmony_ci * limitations under the License.
141e934351Sopenharmony_ci */
151e934351Sopenharmony_ci
161e934351Sopenharmony_ci/**
171e934351Sopenharmony_ci * @file
181e934351Sopenharmony_ci * @kit NetworkKit
191e934351Sopenharmony_ci */
201e934351Sopenharmony_ci
211e934351Sopenharmony_ciimport type { AsyncCallback, ErrorCallback, Callback } from './@ohos.base';
221e934351Sopenharmony_ciimport type connection from './@ohos.net.connection';
231e934351Sopenharmony_ci
241e934351Sopenharmony_ci/**
251e934351Sopenharmony_ci * Provides WebSocket APIs.
261e934351Sopenharmony_ci * @namespace webSocket
271e934351Sopenharmony_ci * @syscap SystemCapability.Communication.NetStack
281e934351Sopenharmony_ci * @since 6
291e934351Sopenharmony_ci */
301e934351Sopenharmony_ci/**
311e934351Sopenharmony_ci * Provides WebSocket APIs.
321e934351Sopenharmony_ci * @namespace webSocket
331e934351Sopenharmony_ci * @syscap SystemCapability.Communication.NetStack
341e934351Sopenharmony_ci * @crossplatform
351e934351Sopenharmony_ci * @since 10
361e934351Sopenharmony_ci */
371e934351Sopenharmony_ci/**
381e934351Sopenharmony_ci * Provides WebSocket APIs.
391e934351Sopenharmony_ci * @namespace webSocket
401e934351Sopenharmony_ci * @syscap SystemCapability.Communication.NetStack
411e934351Sopenharmony_ci * @crossplatform
421e934351Sopenharmony_ci * @atomicservice
431e934351Sopenharmony_ci * @since 11
441e934351Sopenharmony_ci */
451e934351Sopenharmony_cideclare namespace webSocket {
461e934351Sopenharmony_ci  /**
471e934351Sopenharmony_ci   * @typedef { connection.HttpProxy }
481e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetManager.Core
491e934351Sopenharmony_ci   * @since 12
501e934351Sopenharmony_ci   */
511e934351Sopenharmony_ci  type HttpProxy = connection.HttpProxy;
521e934351Sopenharmony_ci
531e934351Sopenharmony_ci  /**
541e934351Sopenharmony_ci   * Creates a web socket connection.
551e934351Sopenharmony_ci   * @returns { WebSocket } the WebSocket of the createWebSocket.
561e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
571e934351Sopenharmony_ci   * @since 6
581e934351Sopenharmony_ci   */
591e934351Sopenharmony_ci  /**
601e934351Sopenharmony_ci   * Creates a web socket connection.
611e934351Sopenharmony_ci   * @returns { WebSocket } the WebSocket of the createWebSocket.
621e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
631e934351Sopenharmony_ci   * @crossplatform
641e934351Sopenharmony_ci   * @since 10
651e934351Sopenharmony_ci   */
661e934351Sopenharmony_ci  /**
671e934351Sopenharmony_ci   * Creates a web socket connection.
681e934351Sopenharmony_ci   * @returns { WebSocket } the WebSocket of the createWebSocket.
691e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
701e934351Sopenharmony_ci   * @crossplatform
711e934351Sopenharmony_ci   * @atomicservice
721e934351Sopenharmony_ci   * @since 11
731e934351Sopenharmony_ci   */
741e934351Sopenharmony_ci  function createWebSocket(): WebSocket;
751e934351Sopenharmony_ci
761e934351Sopenharmony_ci  /**
771e934351Sopenharmony_ci   * Defines the optional parameters carried in the request for establishing a WebSocket connection.
781e934351Sopenharmony_ci   * @interface WebSocketRequestOptions
791e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
801e934351Sopenharmony_ci   * @since 6
811e934351Sopenharmony_ci   */
821e934351Sopenharmony_ci  /**
831e934351Sopenharmony_ci   * Defines the optional parameters carried in the request for establishing a WebSocket connection.
841e934351Sopenharmony_ci   * @interface WebSocketRequestOptions
851e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
861e934351Sopenharmony_ci   * @crossplatform
871e934351Sopenharmony_ci   * @since 10
881e934351Sopenharmony_ci   */
891e934351Sopenharmony_ci  /**
901e934351Sopenharmony_ci   * Defines the optional parameters carried in the request for establishing a WebSocket connection.
911e934351Sopenharmony_ci   * @interface WebSocketRequestOptions
921e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
931e934351Sopenharmony_ci   * @crossplatform
941e934351Sopenharmony_ci   * @atomicservice
951e934351Sopenharmony_ci   * @since 11
961e934351Sopenharmony_ci   */
971e934351Sopenharmony_ci  export interface WebSocketRequestOptions {
981e934351Sopenharmony_ci    /**
991e934351Sopenharmony_ci     * HTTP request header.
1001e934351Sopenharmony_ci     * @type {?Object}
1011e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
1021e934351Sopenharmony_ci     * @since 6
1031e934351Sopenharmony_ci     */
1041e934351Sopenharmony_ci    /**
1051e934351Sopenharmony_ci     * HTTP request header.
1061e934351Sopenharmony_ci     * @type {?Object}
1071e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
1081e934351Sopenharmony_ci     * @crossplatform
1091e934351Sopenharmony_ci     * @since 10
1101e934351Sopenharmony_ci     */
1111e934351Sopenharmony_ci    /**
1121e934351Sopenharmony_ci     * HTTP request header.
1131e934351Sopenharmony_ci     * @type {?Object}
1141e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
1151e934351Sopenharmony_ci     * @crossplatform
1161e934351Sopenharmony_ci     * @atomicservice
1171e934351Sopenharmony_ci     * @since 11
1181e934351Sopenharmony_ci     */
1191e934351Sopenharmony_ci    header?: Object;
1201e934351Sopenharmony_ci
1211e934351Sopenharmony_ci    /**
1221e934351Sopenharmony_ci     * File path for client cert.
1231e934351Sopenharmony_ci     * @type {?string}
1241e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
1251e934351Sopenharmony_ci     * @since 11
1261e934351Sopenharmony_ci     */
1271e934351Sopenharmony_ci    /**
1281e934351Sopenharmony_ci     * File path for client cert.
1291e934351Sopenharmony_ci     * @type {?string}
1301e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
1311e934351Sopenharmony_ci     * @crossplatform
1321e934351Sopenharmony_ci     * @since 12
1331e934351Sopenharmony_ci     */
1341e934351Sopenharmony_ci    caPath?: string;
1351e934351Sopenharmony_ci
1361e934351Sopenharmony_ci    /**
1371e934351Sopenharmony_ci     * Client cert.
1381e934351Sopenharmony_ci     * @type {?ClientCert}
1391e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
1401e934351Sopenharmony_ci     * @since 11
1411e934351Sopenharmony_ci     */
1421e934351Sopenharmony_ci    /**
1431e934351Sopenharmony_ci     * Client cert.
1441e934351Sopenharmony_ci     * @type {?ClientCert}
1451e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
1461e934351Sopenharmony_ci     * @crossplatform
1471e934351Sopenharmony_ci     * @since 12
1481e934351Sopenharmony_ci     */
1491e934351Sopenharmony_ci    clientCert?: ClientCert;
1501e934351Sopenharmony_ci
1511e934351Sopenharmony_ci    /**
1521e934351Sopenharmony_ci     * HTTP proxy configuration. Use 'system' if this filed is not set.
1531e934351Sopenharmony_ci     * @type {?ProxyConfiguration}
1541e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
1551e934351Sopenharmony_ci     * @since 12
1561e934351Sopenharmony_ci     */
1571e934351Sopenharmony_ci    proxy?: ProxyConfiguration;
1581e934351Sopenharmony_ci
1591e934351Sopenharmony_ci    /**
1601e934351Sopenharmony_ci     * Self defined protocol.
1611e934351Sopenharmony_ci     * @type {?string}
1621e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
1631e934351Sopenharmony_ci     * @since 12
1641e934351Sopenharmony_ci     */
1651e934351Sopenharmony_ci    protocol?: string;
1661e934351Sopenharmony_ci  }
1671e934351Sopenharmony_ci
1681e934351Sopenharmony_ci  /**
1691e934351Sopenharmony_ci   * HTTP proxy configuration.
1701e934351Sopenharmony_ci   * system: means that use system proxy configuration.
1711e934351Sopenharmony_ci   * no-proxy: means do not use proxy.
1721e934351Sopenharmony_ci   * object of @type {connection.HttpProxy} means providing custom proxy settings
1731e934351Sopenharmony_ci   * @typedef { 'system' | 'no-proxy' | HttpProxy }
1741e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
1751e934351Sopenharmony_ci   * @since 12
1761e934351Sopenharmony_ci   */
1771e934351Sopenharmony_ci  export type ProxyConfiguration = 'system' | 'no-proxy' | HttpProxy;
1781e934351Sopenharmony_ci
1791e934351Sopenharmony_ci  /**
1801e934351Sopenharmony_ci   * The clientCert field of the client certificate, which includes three attributes:
1811e934351Sopenharmony_ci   * client certificate (certPath) and only support PEM format, certificate private key (keyPath), 
1821e934351Sopenharmony_ci   * and passphrase (keyPassword).
1831e934351Sopenharmony_ci   * @interface ClientCert
1841e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
1851e934351Sopenharmony_ci   * @since 11
1861e934351Sopenharmony_ci   */
1871e934351Sopenharmony_ci  /**
1881e934351Sopenharmony_ci   * The clientCert field of the client certificate, which includes three attributes:
1891e934351Sopenharmony_ci   * client certificate (certPath) and only support PEM format, certificate private key (keyPath), 
1901e934351Sopenharmony_ci   * and passphrase (keyPassword).
1911e934351Sopenharmony_ci   * @interface ClientCert
1921e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
1931e934351Sopenharmony_ci   * @crossplatform
1941e934351Sopenharmony_ci   * @since 12
1951e934351Sopenharmony_ci   */
1961e934351Sopenharmony_ci  export interface ClientCert {
1971e934351Sopenharmony_ci    /**
1981e934351Sopenharmony_ci     * The path to the client certificate file.
1991e934351Sopenharmony_ci     * @type {string}
2001e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
2011e934351Sopenharmony_ci     * @since 11
2021e934351Sopenharmony_ci     */
2031e934351Sopenharmony_ci    /**
2041e934351Sopenharmony_ci     * The path to the client certificate file.
2051e934351Sopenharmony_ci     * @type {string}
2061e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
2071e934351Sopenharmony_ci     * @crossplatform
2081e934351Sopenharmony_ci     * @since 12
2091e934351Sopenharmony_ci     */
2101e934351Sopenharmony_ci    certPath: string;
2111e934351Sopenharmony_ci    
2121e934351Sopenharmony_ci    /**
2131e934351Sopenharmony_ci     * The path of the client certificate private key file.
2141e934351Sopenharmony_ci     * @type {string}
2151e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
2161e934351Sopenharmony_ci     * @since 11
2171e934351Sopenharmony_ci     */
2181e934351Sopenharmony_ci    /**
2191e934351Sopenharmony_ci     * The path of the client certificate private key file.
2201e934351Sopenharmony_ci     * @type {string}
2211e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
2221e934351Sopenharmony_ci     * @crossplatform
2231e934351Sopenharmony_ci     * @since 12
2241e934351Sopenharmony_ci     */
2251e934351Sopenharmony_ci    keyPath: string;
2261e934351Sopenharmony_ci
2271e934351Sopenharmony_ci    /**
2281e934351Sopenharmony_ci     * Client certificate password.
2291e934351Sopenharmony_ci     * @type {?string}
2301e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
2311e934351Sopenharmony_ci     * @since 11
2321e934351Sopenharmony_ci     */
2331e934351Sopenharmony_ci    /**
2341e934351Sopenharmony_ci     * Client certificate password.
2351e934351Sopenharmony_ci     * @type {?string}
2361e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
2371e934351Sopenharmony_ci     * @crossplatform
2381e934351Sopenharmony_ci     * @since 12
2391e934351Sopenharmony_ci     */
2401e934351Sopenharmony_ci    keyPassword?: string;
2411e934351Sopenharmony_ci  }
2421e934351Sopenharmony_ci
2431e934351Sopenharmony_ci  /**
2441e934351Sopenharmony_ci   * Defines the optional parameters carried in the request for closing a WebSocket connection.
2451e934351Sopenharmony_ci   * @interface WebSocketCloseOptions
2461e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
2471e934351Sopenharmony_ci   * @since 6
2481e934351Sopenharmony_ci   */
2491e934351Sopenharmony_ci  /**
2501e934351Sopenharmony_ci   * Defines the optional parameters carried in the request for closing a WebSocket connection.
2511e934351Sopenharmony_ci   * @interface WebSocketCloseOptions
2521e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
2531e934351Sopenharmony_ci   * @crossplatform
2541e934351Sopenharmony_ci   * @since 10
2551e934351Sopenharmony_ci   */
2561e934351Sopenharmony_ci  /**
2571e934351Sopenharmony_ci   * Defines the optional parameters carried in the request for closing a WebSocket connection.
2581e934351Sopenharmony_ci   * @interface WebSocketCloseOptions
2591e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
2601e934351Sopenharmony_ci   * @crossplatform
2611e934351Sopenharmony_ci   * @atomicservice
2621e934351Sopenharmony_ci   * @since 11
2631e934351Sopenharmony_ci   */
2641e934351Sopenharmony_ci  export interface WebSocketCloseOptions {
2651e934351Sopenharmony_ci    /**
2661e934351Sopenharmony_ci     * Error code.
2671e934351Sopenharmony_ci     * @type {?number}
2681e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
2691e934351Sopenharmony_ci     * @since 6
2701e934351Sopenharmony_ci     */
2711e934351Sopenharmony_ci    /**
2721e934351Sopenharmony_ci     * Error code.
2731e934351Sopenharmony_ci     * @type {?number}
2741e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
2751e934351Sopenharmony_ci     * @crossplatform
2761e934351Sopenharmony_ci     * @since 10
2771e934351Sopenharmony_ci     */
2781e934351Sopenharmony_ci    /**
2791e934351Sopenharmony_ci     * Error code.
2801e934351Sopenharmony_ci     * @type {?number}
2811e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
2821e934351Sopenharmony_ci     * @crossplatform
2831e934351Sopenharmony_ci     * @atomicservice
2841e934351Sopenharmony_ci     * @since 11
2851e934351Sopenharmony_ci     */
2861e934351Sopenharmony_ci    code?: number;
2871e934351Sopenharmony_ci    /**
2881e934351Sopenharmony_ci     * Error cause.
2891e934351Sopenharmony_ci     * @type {?string}
2901e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
2911e934351Sopenharmony_ci     * @since 6
2921e934351Sopenharmony_ci     */
2931e934351Sopenharmony_ci    /**
2941e934351Sopenharmony_ci     * Error cause.
2951e934351Sopenharmony_ci     * @type {?string}
2961e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
2971e934351Sopenharmony_ci     * @crossplatform
2981e934351Sopenharmony_ci     * @since 10
2991e934351Sopenharmony_ci     */
3001e934351Sopenharmony_ci    /**
3011e934351Sopenharmony_ci     * Error cause.
3021e934351Sopenharmony_ci     * @type {?string}
3031e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
3041e934351Sopenharmony_ci     * @crossplatform
3051e934351Sopenharmony_ci     * @atomicservice
3061e934351Sopenharmony_ci     * @since 11
3071e934351Sopenharmony_ci     */
3081e934351Sopenharmony_ci    reason?: string;
3091e934351Sopenharmony_ci  }
3101e934351Sopenharmony_ci
3111e934351Sopenharmony_ci  /**
3121e934351Sopenharmony_ci   * The result for closing a WebSocket connection.
3131e934351Sopenharmony_ci   * @interface CloseResult
3141e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
3151e934351Sopenharmony_ci   * @crossplatform
3161e934351Sopenharmony_ci   * @since 10
3171e934351Sopenharmony_ci   */
3181e934351Sopenharmony_ci  /**
3191e934351Sopenharmony_ci   * The result for closing a WebSocket connection.
3201e934351Sopenharmony_ci   * @interface CloseResult
3211e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
3221e934351Sopenharmony_ci   * @crossplatform
3231e934351Sopenharmony_ci   * @atomicservice
3241e934351Sopenharmony_ci   * @since 11
3251e934351Sopenharmony_ci   */
3261e934351Sopenharmony_ci  export interface CloseResult {
3271e934351Sopenharmony_ci    /**
3281e934351Sopenharmony_ci     * Error code.
3291e934351Sopenharmony_ci     * @type {number}
3301e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
3311e934351Sopenharmony_ci     * @crossplatform
3321e934351Sopenharmony_ci     * @since 10
3331e934351Sopenharmony_ci     */
3341e934351Sopenharmony_ci    /**
3351e934351Sopenharmony_ci     * Error code.
3361e934351Sopenharmony_ci     * @type {number}
3371e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
3381e934351Sopenharmony_ci     * @crossplatform
3391e934351Sopenharmony_ci     * @atomicservice
3401e934351Sopenharmony_ci     * @since 11
3411e934351Sopenharmony_ci     */
3421e934351Sopenharmony_ci    code: number;
3431e934351Sopenharmony_ci    /**
3441e934351Sopenharmony_ci     * Error cause.
3451e934351Sopenharmony_ci     * @type {string}
3461e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
3471e934351Sopenharmony_ci     * @crossplatform
3481e934351Sopenharmony_ci     * @since 10
3491e934351Sopenharmony_ci     */
3501e934351Sopenharmony_ci    /**
3511e934351Sopenharmony_ci     * Error cause.
3521e934351Sopenharmony_ci     * @type {string}
3531e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
3541e934351Sopenharmony_ci     * @crossplatform
3551e934351Sopenharmony_ci     * @atomicservice
3561e934351Sopenharmony_ci     * @since 11
3571e934351Sopenharmony_ci     */
3581e934351Sopenharmony_ci    reason: string;
3591e934351Sopenharmony_ci  }
3601e934351Sopenharmony_ci
3611e934351Sopenharmony_ci  /**
3621e934351Sopenharmony_ci   * HTTP response headers.
3631e934351Sopenharmony_ci   * @typedef { object }
3641e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
3651e934351Sopenharmony_ci   * @since 12
3661e934351Sopenharmony_ci   */
3671e934351Sopenharmony_ci  export type ResponseHeaders = {
3681e934351Sopenharmony_ci    [k: string]: string | string[] | undefined;
3691e934351Sopenharmony_ci  }
3701e934351Sopenharmony_ci
3711e934351Sopenharmony_ci  /**
3721e934351Sopenharmony_ci   * <p>Defines a WebSocket object. Before invoking WebSocket APIs,
3731e934351Sopenharmony_ci   * you need to call webSocket.createWebSocket to create a WebSocket object.</p>
3741e934351Sopenharmony_ci   * @interface WebSocket
3751e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
3761e934351Sopenharmony_ci   * @since 6
3771e934351Sopenharmony_ci   */
3781e934351Sopenharmony_ci  /**
3791e934351Sopenharmony_ci   * <p>Defines a WebSocket object. Before invoking WebSocket APIs,
3801e934351Sopenharmony_ci   * you need to call webSocket.createWebSocket to create a WebSocket object.</p>
3811e934351Sopenharmony_ci   * @interface WebSocket
3821e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
3831e934351Sopenharmony_ci   * @crossplatform
3841e934351Sopenharmony_ci   * @since 10
3851e934351Sopenharmony_ci   */
3861e934351Sopenharmony_ci  /**
3871e934351Sopenharmony_ci   * <p>Defines a WebSocket object. Before invoking WebSocket APIs,
3881e934351Sopenharmony_ci   * you need to call webSocket.createWebSocket to create a WebSocket object.</p>
3891e934351Sopenharmony_ci   * @interface WebSocket
3901e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
3911e934351Sopenharmony_ci   * @crossplatform
3921e934351Sopenharmony_ci   * @atomicservice
3931e934351Sopenharmony_ci   * @since 11
3941e934351Sopenharmony_ci   */
3951e934351Sopenharmony_ci  export interface WebSocket {
3961e934351Sopenharmony_ci    /**
3971e934351Sopenharmony_ci     * Initiates a WebSocket request to establish a WebSocket connection to a given URL.
3981e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
3991e934351Sopenharmony_ci     * @param { string } url - URL for establishing a WebSocket connection.
4001e934351Sopenharmony_ci     * @param { AsyncCallback<boolean> } callback - the callback of connect.
4011e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
4021e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
4031e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
4041e934351Sopenharmony_ci     * @since 6
4051e934351Sopenharmony_ci     */
4061e934351Sopenharmony_ci    /**
4071e934351Sopenharmony_ci     * Initiates a WebSocket request to establish a WebSocket connection to a given URL.
4081e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
4091e934351Sopenharmony_ci     * @param { string } url URL for establishing a WebSocket connection.
4101e934351Sopenharmony_ci     * @param { AsyncCallback<boolean> } callback - the callback of connect.
4111e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
4121e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
4131e934351Sopenharmony_ci     * @throws { BusinessError } 2302999 - Websocket other unknown error.
4141e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
4151e934351Sopenharmony_ci     * @crossplatform
4161e934351Sopenharmony_ci     * @since 10
4171e934351Sopenharmony_ci     */
4181e934351Sopenharmony_ci    /**
4191e934351Sopenharmony_ci     * Initiates a WebSocket request to establish a WebSocket connection to a given URL.
4201e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
4211e934351Sopenharmony_ci     * @param { string } url URL for establishing a WebSocket connection.
4221e934351Sopenharmony_ci     * @param { AsyncCallback<boolean> } callback - the callback of connect.
4231e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
4241e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
4251e934351Sopenharmony_ci     * @throws { BusinessError } 2302999 - Websocket other unknown error.
4261e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
4271e934351Sopenharmony_ci     * @crossplatform
4281e934351Sopenharmony_ci     * @atomicservice
4291e934351Sopenharmony_ci     * @since 11
4301e934351Sopenharmony_ci     */
4311e934351Sopenharmony_ci    /**
4321e934351Sopenharmony_ci     * Initiates a WebSocket request to establish a WebSocket connection to a given URL.
4331e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
4341e934351Sopenharmony_ci     * @param { string } url URL for establishing a WebSocket connection.
4351e934351Sopenharmony_ci     * @param { AsyncCallback<boolean> } callback - the callback of connect.
4361e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
4371e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
4381e934351Sopenharmony_ci     * @throws { BusinessError } 2302001 - Websocket url error.
4391e934351Sopenharmony_ci     * @throws { BusinessError } 2302002 - Websocket certificate file does not exist.
4401e934351Sopenharmony_ci     * @throws { BusinessError } 2302003 - Websocket connection already exists.
4411e934351Sopenharmony_ci     * @throws { BusinessError } 2302999 - Websocket other unknown error.
4421e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
4431e934351Sopenharmony_ci     * @crossplatform
4441e934351Sopenharmony_ci     * @atomicservice
4451e934351Sopenharmony_ci     * @since 12
4461e934351Sopenharmony_ci     */
4471e934351Sopenharmony_ci    connect(url: string, callback: AsyncCallback<boolean>): void;
4481e934351Sopenharmony_ci
4491e934351Sopenharmony_ci    /**
4501e934351Sopenharmony_ci     * Initiates a WebSocket request to establish a WebSocket connection to a given URL.
4511e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
4521e934351Sopenharmony_ci     * @param { string } url URL for establishing a WebSocket connection.
4531e934351Sopenharmony_ci     * @param { WebSocketRequestOptions } options - Optional parameters {@link WebSocketRequestOptions}.
4541e934351Sopenharmony_ci     * @param { AsyncCallback<boolean> } callback - the callback of connect.
4551e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
4561e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
4571e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
4581e934351Sopenharmony_ci     * @since 6
4591e934351Sopenharmony_ci     */
4601e934351Sopenharmony_ci    /**
4611e934351Sopenharmony_ci     * Initiates a WebSocket request to establish a WebSocket connection to a given URL.
4621e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
4631e934351Sopenharmony_ci     * @param { string } url URL for establishing a WebSocket connection.
4641e934351Sopenharmony_ci     * @param { WebSocketRequestOptions } options - Optional parameters {@link WebSocketRequestOptions}.
4651e934351Sopenharmony_ci     * @param { AsyncCallback<boolean> } callback - the callback of connect.
4661e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
4671e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
4681e934351Sopenharmony_ci     * @throws { BusinessError } 2302999 - Websocket other unknown error.
4691e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
4701e934351Sopenharmony_ci     * @crossplatform
4711e934351Sopenharmony_ci     * @since 10
4721e934351Sopenharmony_ci     */
4731e934351Sopenharmony_ci    /**
4741e934351Sopenharmony_ci     * Initiates a WebSocket request to establish a WebSocket connection to a given URL.
4751e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
4761e934351Sopenharmony_ci     * @param { string } url URL for establishing a WebSocket connection.
4771e934351Sopenharmony_ci     * @param { WebSocketRequestOptions } options - Optional parameters {@link WebSocketRequestOptions}.
4781e934351Sopenharmony_ci     * @param { AsyncCallback<boolean> } callback - the callback of connect.
4791e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
4801e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
4811e934351Sopenharmony_ci     * @throws { BusinessError } 2302999 - Websocket other unknown error.
4821e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
4831e934351Sopenharmony_ci     * @crossplatform
4841e934351Sopenharmony_ci     * @atomicservice
4851e934351Sopenharmony_ci     * @since 11
4861e934351Sopenharmony_ci     */
4871e934351Sopenharmony_ci    /**
4881e934351Sopenharmony_ci     * Initiates a WebSocket request to establish a WebSocket connection to a given URL.
4891e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
4901e934351Sopenharmony_ci     * @param { string } url URL for establishing a WebSocket connection.
4911e934351Sopenharmony_ci     * @param { WebSocketRequestOptions } options - Optional parameters {@link WebSocketRequestOptions}.
4921e934351Sopenharmony_ci     * @param { AsyncCallback<boolean> } callback - the callback of connect.
4931e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
4941e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
4951e934351Sopenharmony_ci     * @throws { BusinessError } 2302001 - Websocket url error.
4961e934351Sopenharmony_ci     * @throws { BusinessError } 2302002 - Websocket certificate file does not exist.
4971e934351Sopenharmony_ci     * @throws { BusinessError } 2302003 - Websocket connection already exists.
4981e934351Sopenharmony_ci     * @throws { BusinessError } 2302999 - Websocket other unknown error.
4991e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
5001e934351Sopenharmony_ci     * @crossplatform
5011e934351Sopenharmony_ci     * @atomicservice
5021e934351Sopenharmony_ci     * @since 12
5031e934351Sopenharmony_ci     */
5041e934351Sopenharmony_ci    connect(url: string, options: WebSocketRequestOptions, callback: AsyncCallback<boolean>): void;
5051e934351Sopenharmony_ci
5061e934351Sopenharmony_ci    /**
5071e934351Sopenharmony_ci     * Initiates a WebSocket request to establish a WebSocket connection to a given URL.
5081e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
5091e934351Sopenharmony_ci     * @param { string } url URL for establishing a WebSocket connection.
5101e934351Sopenharmony_ci     * @param { WebSocketRequestOptions } options - Optional parameters {@link WebSocketRequestOptions}.
5111e934351Sopenharmony_ci     * @returns { Promise<boolean> } The promise returned by the function.
5121e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
5131e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
5141e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
5151e934351Sopenharmony_ci     * @since 6
5161e934351Sopenharmony_ci     */
5171e934351Sopenharmony_ci    /**
5181e934351Sopenharmony_ci     * Initiates a WebSocket request to establish a WebSocket connection to a given URL.
5191e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
5201e934351Sopenharmony_ci     * @param { string } url URL for establishing a WebSocket connection.
5211e934351Sopenharmony_ci     * @param { WebSocketRequestOptions } options - Optional parameters {@link WebSocketRequestOptions}.
5221e934351Sopenharmony_ci     * @returns { Promise<boolean> } The promise returned by the function.
5231e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
5241e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
5251e934351Sopenharmony_ci     * @throws { BusinessError } 2302999 - Websocket other unknown error.
5261e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
5271e934351Sopenharmony_ci     * @crossplatform
5281e934351Sopenharmony_ci     * @since 10
5291e934351Sopenharmony_ci     */
5301e934351Sopenharmony_ci    /**
5311e934351Sopenharmony_ci     * Initiates a WebSocket request to establish a WebSocket connection to a given URL.
5321e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
5331e934351Sopenharmony_ci     * @param { string } url URL for establishing a WebSocket connection.
5341e934351Sopenharmony_ci     * @param { WebSocketRequestOptions } options - Optional parameters {@link WebSocketRequestOptions}.
5351e934351Sopenharmony_ci     * @returns { Promise<boolean> } The promise returned by the function.
5361e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
5371e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
5381e934351Sopenharmony_ci     * @throws { BusinessError } 2302999 - Websocket other unknown error.
5391e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
5401e934351Sopenharmony_ci     * @crossplatform
5411e934351Sopenharmony_ci     * @atomicservice
5421e934351Sopenharmony_ci     * @since 11
5431e934351Sopenharmony_ci     */
5441e934351Sopenharmony_ci    /**
5451e934351Sopenharmony_ci     * Initiates a WebSocket request to establish a WebSocket connection to a given URL.
5461e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
5471e934351Sopenharmony_ci     * @param { string } url URL for establishing a WebSocket connection.
5481e934351Sopenharmony_ci     * @param { WebSocketRequestOptions } options - Optional parameters {@link WebSocketRequestOptions}.
5491e934351Sopenharmony_ci     * @returns { Promise<boolean> } The promise returned by the function.
5501e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
5511e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
5521e934351Sopenharmony_ci     * @throws { BusinessError } 2302001 - Websocket url error.
5531e934351Sopenharmony_ci     * @throws { BusinessError } 2302002 - Websocket certificate file does not exist.
5541e934351Sopenharmony_ci     * @throws { BusinessError } 2302003 - Websocket connection already exists.
5551e934351Sopenharmony_ci     * @throws { BusinessError } 2302999 - Websocket other unknown error.
5561e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
5571e934351Sopenharmony_ci     * @crossplatform
5581e934351Sopenharmony_ci     * @atomicservice
5591e934351Sopenharmony_ci     * @since 12
5601e934351Sopenharmony_ci     */
5611e934351Sopenharmony_ci    connect(url: string, options?: WebSocketRequestOptions): Promise<boolean>;
5621e934351Sopenharmony_ci
5631e934351Sopenharmony_ci    /**
5641e934351Sopenharmony_ci     * Sends data through a WebSocket connection.
5651e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
5661e934351Sopenharmony_ci     * @param { string | ArrayBuffer } data - Data to send. It can be a string(API 6) or an ArrayBuffer(API 8).
5671e934351Sopenharmony_ci     * @param { AsyncCallback<boolean> } callback - the callback of send.
5681e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
5691e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
5701e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
5711e934351Sopenharmony_ci     * @since 6
5721e934351Sopenharmony_ci     */
5731e934351Sopenharmony_ci    /**
5741e934351Sopenharmony_ci     * Sends data through a WebSocket connection.
5751e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
5761e934351Sopenharmony_ci     * @param { string | ArrayBuffer } data - Data to send. It can be a string(API 6) or an ArrayBuffer(API 8).
5771e934351Sopenharmony_ci     * @param { AsyncCallback<boolean> } callback - the callback of send.
5781e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
5791e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
5801e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
5811e934351Sopenharmony_ci     * @crossplatform
5821e934351Sopenharmony_ci     * @since 10
5831e934351Sopenharmony_ci     */
5841e934351Sopenharmony_ci    /**
5851e934351Sopenharmony_ci     * Sends data through a WebSocket connection.
5861e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
5871e934351Sopenharmony_ci     * @param { string | ArrayBuffer } data - Data to send. It can be a string(API 6) or an ArrayBuffer(API 8).
5881e934351Sopenharmony_ci     * @param { AsyncCallback<boolean> } callback - the callback of send.
5891e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
5901e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
5911e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
5921e934351Sopenharmony_ci     * @crossplatform
5931e934351Sopenharmony_ci     * @atomicservice
5941e934351Sopenharmony_ci     * @since 11
5951e934351Sopenharmony_ci     */
5961e934351Sopenharmony_ci    send(data: string | ArrayBuffer, callback: AsyncCallback<boolean>): void;
5971e934351Sopenharmony_ci
5981e934351Sopenharmony_ci    /**
5991e934351Sopenharmony_ci     * Sends data through a WebSocket connection.
6001e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
6011e934351Sopenharmony_ci     * @param { string | ArrayBuffer } data - Data to send. It can be a string(API 6) or an ArrayBuffer(API 8).
6021e934351Sopenharmony_ci     * @returns { Promise<boolean> } The promise returned by the function.
6031e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
6041e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
6051e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
6061e934351Sopenharmony_ci     * @since 6
6071e934351Sopenharmony_ci     */
6081e934351Sopenharmony_ci    /**
6091e934351Sopenharmony_ci     * Sends data through a WebSocket connection.
6101e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
6111e934351Sopenharmony_ci     * @param { string | ArrayBuffer } data - Data to send. It can be a string(API 6) or an ArrayBuffer(API 8).
6121e934351Sopenharmony_ci     * @returns { Promise<boolean> } The promise returned by the function.
6131e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
6141e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
6151e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
6161e934351Sopenharmony_ci     * @crossplatform
6171e934351Sopenharmony_ci     * @since 10
6181e934351Sopenharmony_ci     */
6191e934351Sopenharmony_ci    /**
6201e934351Sopenharmony_ci     * Sends data through a WebSocket connection.
6211e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
6221e934351Sopenharmony_ci     * @param { string | ArrayBuffer } data - Data to send. It can be a string(API 6) or an ArrayBuffer(API 8).
6231e934351Sopenharmony_ci     * @returns { Promise<boolean> } The promise returned by the function.
6241e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
6251e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
6261e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
6271e934351Sopenharmony_ci     * @crossplatform
6281e934351Sopenharmony_ci     * @atomicservice
6291e934351Sopenharmony_ci     * @since 11
6301e934351Sopenharmony_ci     */
6311e934351Sopenharmony_ci    send(data: string | ArrayBuffer): Promise<boolean>;
6321e934351Sopenharmony_ci
6331e934351Sopenharmony_ci    /**
6341e934351Sopenharmony_ci     * Closes a WebSocket connection.
6351e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
6361e934351Sopenharmony_ci     * @param { AsyncCallback<boolean> } callback - the callback of close.
6371e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
6381e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
6391e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
6401e934351Sopenharmony_ci     * @since 6
6411e934351Sopenharmony_ci     */
6421e934351Sopenharmony_ci    /**
6431e934351Sopenharmony_ci     * Closes a WebSocket connection.
6441e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
6451e934351Sopenharmony_ci     * @param { AsyncCallback<boolean> } callback - the callback of close.
6461e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
6471e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
6481e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
6491e934351Sopenharmony_ci     * @crossplatform
6501e934351Sopenharmony_ci     * @since 10
6511e934351Sopenharmony_ci     */
6521e934351Sopenharmony_ci    /**
6531e934351Sopenharmony_ci     * Closes a WebSocket connection.
6541e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
6551e934351Sopenharmony_ci     * @param { AsyncCallback<boolean> } callback - the callback of close.
6561e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
6571e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
6581e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
6591e934351Sopenharmony_ci     * @crossplatform
6601e934351Sopenharmony_ci     * @atomicservice
6611e934351Sopenharmony_ci     * @since 11
6621e934351Sopenharmony_ci     */
6631e934351Sopenharmony_ci    close(callback: AsyncCallback<boolean>): void;
6641e934351Sopenharmony_ci
6651e934351Sopenharmony_ci    /**
6661e934351Sopenharmony_ci     * Closes a WebSocket connection.
6671e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
6681e934351Sopenharmony_ci     * @param { WebSocketCloseOptions } options - Optional parameters {@link WebSocketCloseOptions}.
6691e934351Sopenharmony_ci     * @param { AsyncCallback<boolean> } callback - the callback of close.
6701e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
6711e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
6721e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
6731e934351Sopenharmony_ci     * @since 6
6741e934351Sopenharmony_ci     */
6751e934351Sopenharmony_ci    /**
6761e934351Sopenharmony_ci     * Closes a WebSocket connection.
6771e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
6781e934351Sopenharmony_ci     * @param { WebSocketCloseOptions } options - Optional parameters {@link WebSocketCloseOptions}.
6791e934351Sopenharmony_ci     * @param { AsyncCallback<boolean> } callback - the callback of close.
6801e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
6811e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
6821e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
6831e934351Sopenharmony_ci     * @crossplatform
6841e934351Sopenharmony_ci     * @since 10
6851e934351Sopenharmony_ci     */
6861e934351Sopenharmony_ci    /**
6871e934351Sopenharmony_ci     * Closes a WebSocket connection.
6881e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
6891e934351Sopenharmony_ci     * @param { WebSocketCloseOptions } options - Optional parameters {@link WebSocketCloseOptions}.
6901e934351Sopenharmony_ci     * @param { AsyncCallback<boolean> } callback - the callback of close.
6911e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
6921e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
6931e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
6941e934351Sopenharmony_ci     * @crossplatform
6951e934351Sopenharmony_ci     * @atomicservice
6961e934351Sopenharmony_ci     * @since 11
6971e934351Sopenharmony_ci     */
6981e934351Sopenharmony_ci    close(options: WebSocketCloseOptions, callback: AsyncCallback<boolean>): void;
6991e934351Sopenharmony_ci
7001e934351Sopenharmony_ci    /**
7011e934351Sopenharmony_ci     * Closes a WebSocket connection.
7021e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
7031e934351Sopenharmony_ci     * @param { WebSocketCloseOptions } options - Optional parameters {@link WebSocketCloseOptions}.
7041e934351Sopenharmony_ci     * @returns { Promise<boolean> } The promise returned by the function.
7051e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
7061e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
7071e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
7081e934351Sopenharmony_ci     * @since 6
7091e934351Sopenharmony_ci     */
7101e934351Sopenharmony_ci    /**
7111e934351Sopenharmony_ci     * Closes a WebSocket connection.
7121e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
7131e934351Sopenharmony_ci     * @param { WebSocketCloseOptions } options - Optional parameters {@link WebSocketCloseOptions}.
7141e934351Sopenharmony_ci     * @returns { Promise<boolean> } The promise returned by the function.
7151e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
7161e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
7171e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
7181e934351Sopenharmony_ci     * @crossplatform
7191e934351Sopenharmony_ci     * @since 10
7201e934351Sopenharmony_ci     */
7211e934351Sopenharmony_ci    /**
7221e934351Sopenharmony_ci     * Closes a WebSocket connection.
7231e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
7241e934351Sopenharmony_ci     * @param { WebSocketCloseOptions } options - Optional parameters {@link WebSocketCloseOptions}.
7251e934351Sopenharmony_ci     * @returns { Promise<boolean> } The promise returned by the function.
7261e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
7271e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
7281e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
7291e934351Sopenharmony_ci     * @crossplatform
7301e934351Sopenharmony_ci     * @atomicservice
7311e934351Sopenharmony_ci     * @since 11
7321e934351Sopenharmony_ci     */
7331e934351Sopenharmony_ci    close(options?: WebSocketCloseOptions): Promise<boolean>;
7341e934351Sopenharmony_ci
7351e934351Sopenharmony_ci    /**
7361e934351Sopenharmony_ci     * Enables listening for the open events of a WebSocket connection.
7371e934351Sopenharmony_ci     * @param { 'open' } type - event indicating that a WebSocket connection has been opened.
7381e934351Sopenharmony_ci     * @param { AsyncCallback<Object> } callback - the callback used to return the result.
7391e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
7401e934351Sopenharmony_ci     * @since 6
7411e934351Sopenharmony_ci     */
7421e934351Sopenharmony_ci    /**
7431e934351Sopenharmony_ci     * Enables listening for the open events of a WebSocket connection.
7441e934351Sopenharmony_ci     * @param { 'open' } type - event indicating that a WebSocket connection has been opened.
7451e934351Sopenharmony_ci     * @param { AsyncCallback<Object> } callback - the callback used to return the result.
7461e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
7471e934351Sopenharmony_ci     * @crossplatform
7481e934351Sopenharmony_ci     * @since 10
7491e934351Sopenharmony_ci     */
7501e934351Sopenharmony_ci    /**
7511e934351Sopenharmony_ci     * Enables listening for the open events of a WebSocket connection.
7521e934351Sopenharmony_ci     * @param { 'open' } type - event indicating that a WebSocket connection has been opened.
7531e934351Sopenharmony_ci     * @param { AsyncCallback<Object> } callback - the callback used to return the result.
7541e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
7551e934351Sopenharmony_ci     * @crossplatform
7561e934351Sopenharmony_ci     * @atomicservice
7571e934351Sopenharmony_ci     * @since 11
7581e934351Sopenharmony_ci     */
7591e934351Sopenharmony_ci    on(type: 'open', callback: AsyncCallback<Object>): void;
7601e934351Sopenharmony_ci
7611e934351Sopenharmony_ci    /**
7621e934351Sopenharmony_ci     * Cancels listening for the open events of a WebSocket connection.
7631e934351Sopenharmony_ci     * @param { 'open' } type - event indicating that a WebSocket connection has been opened.
7641e934351Sopenharmony_ci     * @param { AsyncCallback<Object> } callback - the callback used to return the result.
7651e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
7661e934351Sopenharmony_ci     * @since 6
7671e934351Sopenharmony_ci     */
7681e934351Sopenharmony_ci    /**
7691e934351Sopenharmony_ci     * Cancels listening for the open events of a WebSocket connection.
7701e934351Sopenharmony_ci     * @param { 'open' } type - event indicating that a WebSocket connection has been opened.
7711e934351Sopenharmony_ci     * @param { AsyncCallback<Object> } callback the callback used to return the result.
7721e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
7731e934351Sopenharmony_ci     * @crossplatform
7741e934351Sopenharmony_ci     * @since 10
7751e934351Sopenharmony_ci     */
7761e934351Sopenharmony_ci    /**
7771e934351Sopenharmony_ci     * Cancels listening for the open events of a WebSocket connection.
7781e934351Sopenharmony_ci     * @param { 'open' } type - event indicating that a WebSocket connection has been opened.
7791e934351Sopenharmony_ci     * @param { AsyncCallback<Object> } callback the callback used to return the result.
7801e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
7811e934351Sopenharmony_ci     * @crossplatform
7821e934351Sopenharmony_ci     * @atomicservice
7831e934351Sopenharmony_ci     * @since 11
7841e934351Sopenharmony_ci     */
7851e934351Sopenharmony_ci    off(type: 'open', callback?: AsyncCallback<Object>): void;
7861e934351Sopenharmony_ci
7871e934351Sopenharmony_ci    /**
7881e934351Sopenharmony_ci     * Enables listening for the message events of a WebSocket connection.
7891e934351Sopenharmony_ci     * data in AsyncCallback can be a string(API 6) or an ArrayBuffer(API 8).
7901e934351Sopenharmony_ci     * @param { 'message' } type - event indicating that a message has been received from the server.
7911e934351Sopenharmony_ci     * @param { AsyncCallback<string | ArrayBuffer> } callback - the callback used to return the result.
7921e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
7931e934351Sopenharmony_ci     * @since 6
7941e934351Sopenharmony_ci     */
7951e934351Sopenharmony_ci    /**
7961e934351Sopenharmony_ci     * Enables listening for the message events of a WebSocket connection.
7971e934351Sopenharmony_ci     * data in AsyncCallback can be a string(API 6) or an ArrayBuffer(API 8).
7981e934351Sopenharmony_ci     * @param { 'message' } type - event indicating that a message has been received from the server.
7991e934351Sopenharmony_ci     * @param { AsyncCallback<string | ArrayBuffer> } callback - the callback used to return the result.
8001e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
8011e934351Sopenharmony_ci     * @crossplatform
8021e934351Sopenharmony_ci     * @since 10
8031e934351Sopenharmony_ci     */
8041e934351Sopenharmony_ci    /**
8051e934351Sopenharmony_ci     * Enables listening for the message events of a WebSocket connection.
8061e934351Sopenharmony_ci     * data in AsyncCallback can be a string(API 6) or an ArrayBuffer(API 8).
8071e934351Sopenharmony_ci     * @param { 'message' } type - event indicating that a message has been received from the server.
8081e934351Sopenharmony_ci     * @param { AsyncCallback<string | ArrayBuffer> } callback - the callback used to return the result.
8091e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
8101e934351Sopenharmony_ci     * @crossplatform
8111e934351Sopenharmony_ci     * @atomicservice
8121e934351Sopenharmony_ci     * @since 11
8131e934351Sopenharmony_ci     */
8141e934351Sopenharmony_ci    on(type: 'message', callback: AsyncCallback<string | ArrayBuffer>): void;
8151e934351Sopenharmony_ci
8161e934351Sopenharmony_ci    /**
8171e934351Sopenharmony_ci     * Cancels listening for the message events of a WebSocket connection.
8181e934351Sopenharmony_ci     * data in AsyncCallback can be a string(API 6) or an ArrayBuffer(API 8).
8191e934351Sopenharmony_ci     * @param { 'message' } type - event indicating that a message has been received from the server.
8201e934351Sopenharmony_ci     * @param { AsyncCallback<string | ArrayBuffer> } callback - the callback used to return the result.
8211e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
8221e934351Sopenharmony_ci     * @since 6
8231e934351Sopenharmony_ci     */
8241e934351Sopenharmony_ci    /**
8251e934351Sopenharmony_ci     * Cancels listening for the message events of a WebSocket connection.
8261e934351Sopenharmony_ci     * data in AsyncCallback can be a string(API 6) or an ArrayBuffer(API 8).
8271e934351Sopenharmony_ci     * @param { 'message' } type - event indicating that a message has been received from the server.
8281e934351Sopenharmony_ci     * @param { AsyncCallback<string | ArrayBuffer> } callback - the callback used to return the result.
8291e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
8301e934351Sopenharmony_ci     * @crossplatform
8311e934351Sopenharmony_ci     * @since 10
8321e934351Sopenharmony_ci     */
8331e934351Sopenharmony_ci    /**
8341e934351Sopenharmony_ci     * Cancels listening for the message events of a WebSocket connection.
8351e934351Sopenharmony_ci     * data in AsyncCallback can be a string(API 6) or an ArrayBuffer(API 8).
8361e934351Sopenharmony_ci     * @param { 'message' } type - event indicating that a message has been received from the server.
8371e934351Sopenharmony_ci     * @param { AsyncCallback<string | ArrayBuffer> } callback - the callback used to return the result.
8381e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
8391e934351Sopenharmony_ci     * @crossplatform
8401e934351Sopenharmony_ci     * @atomicservice
8411e934351Sopenharmony_ci     * @since 11
8421e934351Sopenharmony_ci     */
8431e934351Sopenharmony_ci    off(type: 'message', callback?: AsyncCallback<string | ArrayBuffer>): void;
8441e934351Sopenharmony_ci
8451e934351Sopenharmony_ci    /**
8461e934351Sopenharmony_ci     * Enables listening for the close events of a WebSocket connection.
8471e934351Sopenharmony_ci     * @param { 'close' } type - event indicating that a WebSocket connection has been closed.
8481e934351Sopenharmony_ci     * @param { AsyncCallback<CloseResult> } callback - the callback used to return the result.
8491e934351Sopenharmony_ci     * <br>close indicates the close error code and reason indicates the error code description.
8501e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
8511e934351Sopenharmony_ci     * @since 6
8521e934351Sopenharmony_ci     */
8531e934351Sopenharmony_ci    /**
8541e934351Sopenharmony_ci     * Enables listening for the close events of a WebSocket connection.
8551e934351Sopenharmony_ci     * @param { 'close' } type - event indicating that a WebSocket connection has been closed.
8561e934351Sopenharmony_ci     * @param { AsyncCallback<CloseResult> } callback - the callback used to return the result.
8571e934351Sopenharmony_ci     * <br>close indicates the close error code and reason indicates the error code description.
8581e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
8591e934351Sopenharmony_ci     * @crossplatform
8601e934351Sopenharmony_ci     * @since 10
8611e934351Sopenharmony_ci     */
8621e934351Sopenharmony_ci    /**
8631e934351Sopenharmony_ci     * Enables listening for the close events of a WebSocket connection.
8641e934351Sopenharmony_ci     * @param { 'close' } type - event indicating that a WebSocket connection has been closed.
8651e934351Sopenharmony_ci     * @param { AsyncCallback<CloseResult> } callback - the callback used to return the result.
8661e934351Sopenharmony_ci     * <br>close indicates the close error code and reason indicates the error code description.
8671e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
8681e934351Sopenharmony_ci     * @crossplatform
8691e934351Sopenharmony_ci     * @atomicservice
8701e934351Sopenharmony_ci     * @since 11
8711e934351Sopenharmony_ci     */
8721e934351Sopenharmony_ci    on(type: 'close', callback: AsyncCallback<CloseResult>): void;
8731e934351Sopenharmony_ci
8741e934351Sopenharmony_ci    /**
8751e934351Sopenharmony_ci     * Cancels listening for the close events of a WebSocket connection.
8761e934351Sopenharmony_ci     * @param { 'close' } type - event indicating that a WebSocket connection has been closed.
8771e934351Sopenharmony_ci     * @param { AsyncCallback<CloseResult> } callback - the callback used to return the result.
8781e934351Sopenharmony_ci     * <br>close indicates the close error code and reason indicates the error code description.
8791e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
8801e934351Sopenharmony_ci     * @since 6
8811e934351Sopenharmony_ci     */
8821e934351Sopenharmony_ci    /**
8831e934351Sopenharmony_ci     * Cancels listening for the close events of a WebSocket connection.
8841e934351Sopenharmony_ci     * @param { 'close' } type - event indicating that a WebSocket connection has been closed.
8851e934351Sopenharmony_ci     * @param { AsyncCallback<CloseResult> } callback - the callback used to return the result.
8861e934351Sopenharmony_ci     * <br>close indicates the close error code and reason indicates the error code description.
8871e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
8881e934351Sopenharmony_ci     * @crossplatform
8891e934351Sopenharmony_ci     * @since 10
8901e934351Sopenharmony_ci     */
8911e934351Sopenharmony_ci    /**
8921e934351Sopenharmony_ci     * Cancels listening for the close events of a WebSocket connection.
8931e934351Sopenharmony_ci     * @param { 'close' } type - event indicating that a WebSocket connection has been closed.
8941e934351Sopenharmony_ci     * @param { AsyncCallback<CloseResult> } callback - the callback used to return the result.
8951e934351Sopenharmony_ci     * <br>close indicates the close error code and reason indicates the error code description.
8961e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
8971e934351Sopenharmony_ci     * @crossplatform
8981e934351Sopenharmony_ci     * @atomicservice
8991e934351Sopenharmony_ci     * @since 11
9001e934351Sopenharmony_ci     */
9011e934351Sopenharmony_ci    off(type: 'close', callback?: AsyncCallback<CloseResult>): void;
9021e934351Sopenharmony_ci
9031e934351Sopenharmony_ci    /**
9041e934351Sopenharmony_ci     * Enables listening for the error events of a WebSocket connection.
9051e934351Sopenharmony_ci     * @param { 'error' } type - event indicating the WebSocket connection has encountered an error.
9061e934351Sopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
9071e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
9081e934351Sopenharmony_ci     * @since 6
9091e934351Sopenharmony_ci     */
9101e934351Sopenharmony_ci    /**
9111e934351Sopenharmony_ci     * Enables listening for the error events of a WebSocket connection.
9121e934351Sopenharmony_ci     * @param { 'error' } type - event indicating the WebSocket connection has encountered an error.
9131e934351Sopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
9141e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
9151e934351Sopenharmony_ci     * @crossplatform
9161e934351Sopenharmony_ci     * @since 10
9171e934351Sopenharmony_ci     */
9181e934351Sopenharmony_ci    /**
9191e934351Sopenharmony_ci     * Enables listening for the error events of a WebSocket connection.
9201e934351Sopenharmony_ci     * @param { 'error' } type - event indicating the WebSocket connection has encountered an error.
9211e934351Sopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
9221e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
9231e934351Sopenharmony_ci     * @crossplatform
9241e934351Sopenharmony_ci     * @atomicservice
9251e934351Sopenharmony_ci     * @since 11
9261e934351Sopenharmony_ci     */
9271e934351Sopenharmony_ci    on(type: 'error', callback: ErrorCallback): void;
9281e934351Sopenharmony_ci
9291e934351Sopenharmony_ci    /**
9301e934351Sopenharmony_ci     * Cancels listening for the error events of a WebSocket connection.
9311e934351Sopenharmony_ci     * @param { 'error' } type - event indicating the WebSocket connection has encountered an error.
9321e934351Sopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
9331e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
9341e934351Sopenharmony_ci     * @since 6
9351e934351Sopenharmony_ci     */
9361e934351Sopenharmony_ci    /**
9371e934351Sopenharmony_ci     * Cancels listening for the error events of a WebSocket connection.
9381e934351Sopenharmony_ci     * @param { 'error' } type - event indicating the WebSocket connection has encountered an error.
9391e934351Sopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
9401e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
9411e934351Sopenharmony_ci     * @crossplatform
9421e934351Sopenharmony_ci     * @since 10
9431e934351Sopenharmony_ci     */
9441e934351Sopenharmony_ci    /**
9451e934351Sopenharmony_ci     * Cancels listening for the error events of a WebSocket connection.
9461e934351Sopenharmony_ci     * @param { 'error' } type - event indicating the WebSocket connection has encountered an error.
9471e934351Sopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
9481e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
9491e934351Sopenharmony_ci     * @crossplatform
9501e934351Sopenharmony_ci     * @atomicservice
9511e934351Sopenharmony_ci     * @since 11
9521e934351Sopenharmony_ci     */
9531e934351Sopenharmony_ci    off(type: 'error', callback?: ErrorCallback): void;
9541e934351Sopenharmony_ci
9551e934351Sopenharmony_ci    /**
9561e934351Sopenharmony_ci     * Enables listening for receiving data ends events of a WebSocket connection.
9571e934351Sopenharmony_ci     * @param { 'dataEnd' } type - event indicating the WebSocket connection has received data ends.
9581e934351Sopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
9591e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
9601e934351Sopenharmony_ci     * @since 11
9611e934351Sopenharmony_ci     */
9621e934351Sopenharmony_ci    /**
9631e934351Sopenharmony_ci     * Enables listening for receiving data ends events of a WebSocket connection.
9641e934351Sopenharmony_ci     * @param { 'dataEnd' } type - event indicating the WebSocket connection has received data ends.
9651e934351Sopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
9661e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
9671e934351Sopenharmony_ci     * @crossplatform
9681e934351Sopenharmony_ci     * @since 12
9691e934351Sopenharmony_ci     */
9701e934351Sopenharmony_ci    on(type: 'dataEnd', callback: Callback<void>): void;
9711e934351Sopenharmony_ci
9721e934351Sopenharmony_ci    /**
9731e934351Sopenharmony_ci     * Cancels listening for receiving data ends events of a WebSocket connection.
9741e934351Sopenharmony_ci     * @param { 'dataEnd' } type - event indicating the WebSocket connection has received data ends.
9751e934351Sopenharmony_ci     * @param { Callback<void> } [ callback ] - the callback used to return the result.
9761e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
9771e934351Sopenharmony_ci     * @since 11
9781e934351Sopenharmony_ci     */
9791e934351Sopenharmony_ci    /**
9801e934351Sopenharmony_ci     * Cancels listening for receiving data ends events of a WebSocket connection.
9811e934351Sopenharmony_ci     * @param { 'dataEnd' } type - event indicating the WebSocket connection has received data ends.
9821e934351Sopenharmony_ci     * @param { Callback<void> } [ callback ] - the callback used to return the result.
9831e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
9841e934351Sopenharmony_ci     * @crossplatform
9851e934351Sopenharmony_ci     * @since 12
9861e934351Sopenharmony_ci     */
9871e934351Sopenharmony_ci    off(type: 'dataEnd', callback?: Callback<void>): void;
9881e934351Sopenharmony_ci
9891e934351Sopenharmony_ci    /**
9901e934351Sopenharmony_ci     * Registers an observer for HTTP Response Header events.
9911e934351Sopenharmony_ci     * @param { 'headerReceive'} type - Indicates Event name.
9921e934351Sopenharmony_ci     * @param { Callback<ResponseHeaders> } callback - the callback used to return the result.
9931e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
9941e934351Sopenharmony_ci     * @since 12
9951e934351Sopenharmony_ci     */
9961e934351Sopenharmony_ci    on(type: 'headerReceive', callback: Callback<ResponseHeaders>): void;
9971e934351Sopenharmony_ci
9981e934351Sopenharmony_ci    /**
9991e934351Sopenharmony_ci     * Unregisters the observer for HTTP Response Header events.
10001e934351Sopenharmony_ci     * @param { 'headerReceive' } type - Indicates Event name.
10011e934351Sopenharmony_ci     * @param { Callback<ResponseHeaders> } [callback] - the callback used to return the result.
10021e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
10031e934351Sopenharmony_ci     * @since 12
10041e934351Sopenharmony_ci     */
10051e934351Sopenharmony_ci    off(type: 'headerReceive', callback?: Callback<ResponseHeaders>): void;
10061e934351Sopenharmony_ci  }
10071e934351Sopenharmony_ci}
10081e934351Sopenharmony_ci
10091e934351Sopenharmony_ciexport default webSocket;