161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (c) 2022-2023 Huawei Device Co., Ltd. 361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 461847f8eSopenharmony_ci * you may not use this file except in compliance with the License. 561847f8eSopenharmony_ci * You may obtain a copy of the License at 661847f8eSopenharmony_ci * 761847f8eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 861847f8eSopenharmony_ci * 961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and 1361847f8eSopenharmony_ci * limitations under the License. 1461847f8eSopenharmony_ci */ 1561847f8eSopenharmony_ci 1661847f8eSopenharmony_ci/** 1761847f8eSopenharmony_ci * @file 1861847f8eSopenharmony_ci * @kit NetworkKit 1961847f8eSopenharmony_ci */ 2061847f8eSopenharmony_ci 2161847f8eSopenharmony_ciimport type { AsyncCallback, ErrorCallback, Callback } from './@ohos.base'; 2261847f8eSopenharmony_ciimport type connection from './@ohos.net.connection'; 2361847f8eSopenharmony_ci 2461847f8eSopenharmony_ci/** 2561847f8eSopenharmony_ci * Provides WebSocket APIs. 2661847f8eSopenharmony_ci * @namespace webSocket 2761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 2861847f8eSopenharmony_ci * @since 6 2961847f8eSopenharmony_ci */ 3061847f8eSopenharmony_ci/** 3161847f8eSopenharmony_ci * Provides WebSocket APIs. 3261847f8eSopenharmony_ci * @namespace webSocket 3361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 3461847f8eSopenharmony_ci * @crossplatform 3561847f8eSopenharmony_ci * @since 10 3661847f8eSopenharmony_ci */ 3761847f8eSopenharmony_ci/** 3861847f8eSopenharmony_ci * Provides WebSocket APIs. 3961847f8eSopenharmony_ci * @namespace webSocket 4061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 4161847f8eSopenharmony_ci * @crossplatform 4261847f8eSopenharmony_ci * @atomicservice 4361847f8eSopenharmony_ci * @since 11 4461847f8eSopenharmony_ci */ 4561847f8eSopenharmony_cideclare namespace webSocket { 4661847f8eSopenharmony_ci /** 4761847f8eSopenharmony_ci * @typedef { connection.HttpProxy } 4861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetManager.Core 4961847f8eSopenharmony_ci * @since 12 5061847f8eSopenharmony_ci */ 5161847f8eSopenharmony_ci type HttpProxy = connection.HttpProxy; 5261847f8eSopenharmony_ci 5361847f8eSopenharmony_ci /** 5461847f8eSopenharmony_ci * Creates a web socket connection. 5561847f8eSopenharmony_ci * @returns { WebSocket } the WebSocket of the createWebSocket. 5661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 5761847f8eSopenharmony_ci * @since 6 5861847f8eSopenharmony_ci */ 5961847f8eSopenharmony_ci /** 6061847f8eSopenharmony_ci * Creates a web socket connection. 6161847f8eSopenharmony_ci * @returns { WebSocket } the WebSocket of the createWebSocket. 6261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 6361847f8eSopenharmony_ci * @crossplatform 6461847f8eSopenharmony_ci * @since 10 6561847f8eSopenharmony_ci */ 6661847f8eSopenharmony_ci /** 6761847f8eSopenharmony_ci * Creates a web socket connection. 6861847f8eSopenharmony_ci * @returns { WebSocket } the WebSocket of the createWebSocket. 6961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 7061847f8eSopenharmony_ci * @crossplatform 7161847f8eSopenharmony_ci * @atomicservice 7261847f8eSopenharmony_ci * @since 11 7361847f8eSopenharmony_ci */ 7461847f8eSopenharmony_ci function createWebSocket(): WebSocket; 7561847f8eSopenharmony_ci 7661847f8eSopenharmony_ci /** 7761847f8eSopenharmony_ci * Defines the optional parameters carried in the request for establishing a WebSocket connection. 7861847f8eSopenharmony_ci * @interface WebSocketRequestOptions 7961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 8061847f8eSopenharmony_ci * @since 6 8161847f8eSopenharmony_ci */ 8261847f8eSopenharmony_ci /** 8361847f8eSopenharmony_ci * Defines the optional parameters carried in the request for establishing a WebSocket connection. 8461847f8eSopenharmony_ci * @interface WebSocketRequestOptions 8561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 8661847f8eSopenharmony_ci * @crossplatform 8761847f8eSopenharmony_ci * @since 10 8861847f8eSopenharmony_ci */ 8961847f8eSopenharmony_ci /** 9061847f8eSopenharmony_ci * Defines the optional parameters carried in the request for establishing a WebSocket connection. 9161847f8eSopenharmony_ci * @interface WebSocketRequestOptions 9261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 9361847f8eSopenharmony_ci * @crossplatform 9461847f8eSopenharmony_ci * @atomicservice 9561847f8eSopenharmony_ci * @since 11 9661847f8eSopenharmony_ci */ 9761847f8eSopenharmony_ci export interface WebSocketRequestOptions { 9861847f8eSopenharmony_ci /** 9961847f8eSopenharmony_ci * HTTP request header. 10061847f8eSopenharmony_ci * @type {?Object} 10161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 10261847f8eSopenharmony_ci * @since 6 10361847f8eSopenharmony_ci */ 10461847f8eSopenharmony_ci /** 10561847f8eSopenharmony_ci * HTTP request header. 10661847f8eSopenharmony_ci * @type {?Object} 10761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 10861847f8eSopenharmony_ci * @crossplatform 10961847f8eSopenharmony_ci * @since 10 11061847f8eSopenharmony_ci */ 11161847f8eSopenharmony_ci /** 11261847f8eSopenharmony_ci * HTTP request header. 11361847f8eSopenharmony_ci * @type {?Object} 11461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 11561847f8eSopenharmony_ci * @crossplatform 11661847f8eSopenharmony_ci * @atomicservice 11761847f8eSopenharmony_ci * @since 11 11861847f8eSopenharmony_ci */ 11961847f8eSopenharmony_ci header?: Object; 12061847f8eSopenharmony_ci 12161847f8eSopenharmony_ci /** 12261847f8eSopenharmony_ci * File path for client cert. 12361847f8eSopenharmony_ci * @type {?string} 12461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 12561847f8eSopenharmony_ci * @since 11 12661847f8eSopenharmony_ci */ 12761847f8eSopenharmony_ci /** 12861847f8eSopenharmony_ci * File path for client cert. 12961847f8eSopenharmony_ci * @type {?string} 13061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 13161847f8eSopenharmony_ci * @crossplatform 13261847f8eSopenharmony_ci * @since 12 13361847f8eSopenharmony_ci */ 13461847f8eSopenharmony_ci caPath?: string; 13561847f8eSopenharmony_ci 13661847f8eSopenharmony_ci /** 13761847f8eSopenharmony_ci * Client cert. 13861847f8eSopenharmony_ci * @type {?ClientCert} 13961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 14061847f8eSopenharmony_ci * @since 11 14161847f8eSopenharmony_ci */ 14261847f8eSopenharmony_ci /** 14361847f8eSopenharmony_ci * Client cert. 14461847f8eSopenharmony_ci * @type {?ClientCert} 14561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 14661847f8eSopenharmony_ci * @crossplatform 14761847f8eSopenharmony_ci * @since 12 14861847f8eSopenharmony_ci */ 14961847f8eSopenharmony_ci clientCert?: ClientCert; 15061847f8eSopenharmony_ci 15161847f8eSopenharmony_ci /** 15261847f8eSopenharmony_ci * HTTP proxy configuration. Use 'system' if this filed is not set. 15361847f8eSopenharmony_ci * @type {?ProxyConfiguration} 15461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 15561847f8eSopenharmony_ci * @since 12 15661847f8eSopenharmony_ci */ 15761847f8eSopenharmony_ci proxy?: ProxyConfiguration; 15861847f8eSopenharmony_ci 15961847f8eSopenharmony_ci /** 16061847f8eSopenharmony_ci * Self defined protocol. 16161847f8eSopenharmony_ci * @type {?string} 16261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 16361847f8eSopenharmony_ci * @since 12 16461847f8eSopenharmony_ci */ 16561847f8eSopenharmony_ci protocol?: string; 16661847f8eSopenharmony_ci } 16761847f8eSopenharmony_ci 16861847f8eSopenharmony_ci /** 16961847f8eSopenharmony_ci * HTTP proxy configuration. 17061847f8eSopenharmony_ci * system: means that use system proxy configuration. 17161847f8eSopenharmony_ci * no-proxy: means do not use proxy. 17261847f8eSopenharmony_ci * object of @type {connection.HttpProxy} means providing custom proxy settings 17361847f8eSopenharmony_ci * @typedef { 'system' | 'no-proxy' | HttpProxy } 17461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 17561847f8eSopenharmony_ci * @since 12 17661847f8eSopenharmony_ci */ 17761847f8eSopenharmony_ci export type ProxyConfiguration = 'system' | 'no-proxy' | HttpProxy; 17861847f8eSopenharmony_ci 17961847f8eSopenharmony_ci /** 18061847f8eSopenharmony_ci * The clientCert field of the client certificate, which includes three attributes: 18161847f8eSopenharmony_ci * client certificate (certPath) and only support PEM format, certificate private key (keyPath), 18261847f8eSopenharmony_ci * and passphrase (keyPassword). 18361847f8eSopenharmony_ci * @interface ClientCert 18461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 18561847f8eSopenharmony_ci * @since 11 18661847f8eSopenharmony_ci */ 18761847f8eSopenharmony_ci /** 18861847f8eSopenharmony_ci * The clientCert field of the client certificate, which includes three attributes: 18961847f8eSopenharmony_ci * client certificate (certPath) and only support PEM format, certificate private key (keyPath), 19061847f8eSopenharmony_ci * and passphrase (keyPassword). 19161847f8eSopenharmony_ci * @interface ClientCert 19261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 19361847f8eSopenharmony_ci * @crossplatform 19461847f8eSopenharmony_ci * @since 12 19561847f8eSopenharmony_ci */ 19661847f8eSopenharmony_ci export interface ClientCert { 19761847f8eSopenharmony_ci /** 19861847f8eSopenharmony_ci * The path to the client certificate file. 19961847f8eSopenharmony_ci * @type {string} 20061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 20161847f8eSopenharmony_ci * @since 11 20261847f8eSopenharmony_ci */ 20361847f8eSopenharmony_ci /** 20461847f8eSopenharmony_ci * The path to the client certificate file. 20561847f8eSopenharmony_ci * @type {string} 20661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 20761847f8eSopenharmony_ci * @crossplatform 20861847f8eSopenharmony_ci * @since 12 20961847f8eSopenharmony_ci */ 21061847f8eSopenharmony_ci certPath: string; 21161847f8eSopenharmony_ci 21261847f8eSopenharmony_ci /** 21361847f8eSopenharmony_ci * The path of the client certificate private key file. 21461847f8eSopenharmony_ci * @type {string} 21561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 21661847f8eSopenharmony_ci * @since 11 21761847f8eSopenharmony_ci */ 21861847f8eSopenharmony_ci /** 21961847f8eSopenharmony_ci * The path of the client certificate private key file. 22061847f8eSopenharmony_ci * @type {string} 22161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 22261847f8eSopenharmony_ci * @crossplatform 22361847f8eSopenharmony_ci * @since 12 22461847f8eSopenharmony_ci */ 22561847f8eSopenharmony_ci keyPath: string; 22661847f8eSopenharmony_ci 22761847f8eSopenharmony_ci /** 22861847f8eSopenharmony_ci * Client certificate password. 22961847f8eSopenharmony_ci * @type {?string} 23061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 23161847f8eSopenharmony_ci * @since 11 23261847f8eSopenharmony_ci */ 23361847f8eSopenharmony_ci /** 23461847f8eSopenharmony_ci * Client certificate password. 23561847f8eSopenharmony_ci * @type {?string} 23661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 23761847f8eSopenharmony_ci * @crossplatform 23861847f8eSopenharmony_ci * @since 12 23961847f8eSopenharmony_ci */ 24061847f8eSopenharmony_ci keyPassword?: string; 24161847f8eSopenharmony_ci } 24261847f8eSopenharmony_ci 24361847f8eSopenharmony_ci /** 24461847f8eSopenharmony_ci * Defines the optional parameters carried in the request for closing a WebSocket connection. 24561847f8eSopenharmony_ci * @interface WebSocketCloseOptions 24661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 24761847f8eSopenharmony_ci * @since 6 24861847f8eSopenharmony_ci */ 24961847f8eSopenharmony_ci /** 25061847f8eSopenharmony_ci * Defines the optional parameters carried in the request for closing a WebSocket connection. 25161847f8eSopenharmony_ci * @interface WebSocketCloseOptions 25261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 25361847f8eSopenharmony_ci * @crossplatform 25461847f8eSopenharmony_ci * @since 10 25561847f8eSopenharmony_ci */ 25661847f8eSopenharmony_ci /** 25761847f8eSopenharmony_ci * Defines the optional parameters carried in the request for closing a WebSocket connection. 25861847f8eSopenharmony_ci * @interface WebSocketCloseOptions 25961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 26061847f8eSopenharmony_ci * @crossplatform 26161847f8eSopenharmony_ci * @atomicservice 26261847f8eSopenharmony_ci * @since 11 26361847f8eSopenharmony_ci */ 26461847f8eSopenharmony_ci export interface WebSocketCloseOptions { 26561847f8eSopenharmony_ci /** 26661847f8eSopenharmony_ci * Error code. 26761847f8eSopenharmony_ci * @type {?number} 26861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 26961847f8eSopenharmony_ci * @since 6 27061847f8eSopenharmony_ci */ 27161847f8eSopenharmony_ci /** 27261847f8eSopenharmony_ci * Error code. 27361847f8eSopenharmony_ci * @type {?number} 27461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 27561847f8eSopenharmony_ci * @crossplatform 27661847f8eSopenharmony_ci * @since 10 27761847f8eSopenharmony_ci */ 27861847f8eSopenharmony_ci /** 27961847f8eSopenharmony_ci * Error code. 28061847f8eSopenharmony_ci * @type {?number} 28161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 28261847f8eSopenharmony_ci * @crossplatform 28361847f8eSopenharmony_ci * @atomicservice 28461847f8eSopenharmony_ci * @since 11 28561847f8eSopenharmony_ci */ 28661847f8eSopenharmony_ci code?: number; 28761847f8eSopenharmony_ci /** 28861847f8eSopenharmony_ci * Error cause. 28961847f8eSopenharmony_ci * @type {?string} 29061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 29161847f8eSopenharmony_ci * @since 6 29261847f8eSopenharmony_ci */ 29361847f8eSopenharmony_ci /** 29461847f8eSopenharmony_ci * Error cause. 29561847f8eSopenharmony_ci * @type {?string} 29661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 29761847f8eSopenharmony_ci * @crossplatform 29861847f8eSopenharmony_ci * @since 10 29961847f8eSopenharmony_ci */ 30061847f8eSopenharmony_ci /** 30161847f8eSopenharmony_ci * Error cause. 30261847f8eSopenharmony_ci * @type {?string} 30361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 30461847f8eSopenharmony_ci * @crossplatform 30561847f8eSopenharmony_ci * @atomicservice 30661847f8eSopenharmony_ci * @since 11 30761847f8eSopenharmony_ci */ 30861847f8eSopenharmony_ci reason?: string; 30961847f8eSopenharmony_ci } 31061847f8eSopenharmony_ci 31161847f8eSopenharmony_ci /** 31261847f8eSopenharmony_ci * The result for closing a WebSocket connection. 31361847f8eSopenharmony_ci * @interface CloseResult 31461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 31561847f8eSopenharmony_ci * @crossplatform 31661847f8eSopenharmony_ci * @since 10 31761847f8eSopenharmony_ci */ 31861847f8eSopenharmony_ci /** 31961847f8eSopenharmony_ci * The result for closing a WebSocket connection. 32061847f8eSopenharmony_ci * @interface CloseResult 32161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 32261847f8eSopenharmony_ci * @crossplatform 32361847f8eSopenharmony_ci * @atomicservice 32461847f8eSopenharmony_ci * @since 11 32561847f8eSopenharmony_ci */ 32661847f8eSopenharmony_ci export interface CloseResult { 32761847f8eSopenharmony_ci /** 32861847f8eSopenharmony_ci * Error code. 32961847f8eSopenharmony_ci * @type {number} 33061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 33161847f8eSopenharmony_ci * @crossplatform 33261847f8eSopenharmony_ci * @since 10 33361847f8eSopenharmony_ci */ 33461847f8eSopenharmony_ci /** 33561847f8eSopenharmony_ci * Error code. 33661847f8eSopenharmony_ci * @type {number} 33761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 33861847f8eSopenharmony_ci * @crossplatform 33961847f8eSopenharmony_ci * @atomicservice 34061847f8eSopenharmony_ci * @since 11 34161847f8eSopenharmony_ci */ 34261847f8eSopenharmony_ci code: number; 34361847f8eSopenharmony_ci /** 34461847f8eSopenharmony_ci * Error cause. 34561847f8eSopenharmony_ci * @type {string} 34661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 34761847f8eSopenharmony_ci * @crossplatform 34861847f8eSopenharmony_ci * @since 10 34961847f8eSopenharmony_ci */ 35061847f8eSopenharmony_ci /** 35161847f8eSopenharmony_ci * Error cause. 35261847f8eSopenharmony_ci * @type {string} 35361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 35461847f8eSopenharmony_ci * @crossplatform 35561847f8eSopenharmony_ci * @atomicservice 35661847f8eSopenharmony_ci * @since 11 35761847f8eSopenharmony_ci */ 35861847f8eSopenharmony_ci reason: string; 35961847f8eSopenharmony_ci } 36061847f8eSopenharmony_ci 36161847f8eSopenharmony_ci /** 36261847f8eSopenharmony_ci * HTTP response headers. 36361847f8eSopenharmony_ci * @typedef { object } 36461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 36561847f8eSopenharmony_ci * @since 12 36661847f8eSopenharmony_ci */ 36761847f8eSopenharmony_ci export type ResponseHeaders = { 36861847f8eSopenharmony_ci [k: string]: string | string[] | undefined; 36961847f8eSopenharmony_ci } 37061847f8eSopenharmony_ci 37161847f8eSopenharmony_ci /** 37261847f8eSopenharmony_ci * <p>Defines a WebSocket object. Before invoking WebSocket APIs, 37361847f8eSopenharmony_ci * you need to call webSocket.createWebSocket to create a WebSocket object.</p> 37461847f8eSopenharmony_ci * @interface WebSocket 37561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 37661847f8eSopenharmony_ci * @since 6 37761847f8eSopenharmony_ci */ 37861847f8eSopenharmony_ci /** 37961847f8eSopenharmony_ci * <p>Defines a WebSocket object. Before invoking WebSocket APIs, 38061847f8eSopenharmony_ci * you need to call webSocket.createWebSocket to create a WebSocket object.</p> 38161847f8eSopenharmony_ci * @interface WebSocket 38261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 38361847f8eSopenharmony_ci * @crossplatform 38461847f8eSopenharmony_ci * @since 10 38561847f8eSopenharmony_ci */ 38661847f8eSopenharmony_ci /** 38761847f8eSopenharmony_ci * <p>Defines a WebSocket object. Before invoking WebSocket APIs, 38861847f8eSopenharmony_ci * you need to call webSocket.createWebSocket to create a WebSocket object.</p> 38961847f8eSopenharmony_ci * @interface WebSocket 39061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 39161847f8eSopenharmony_ci * @crossplatform 39261847f8eSopenharmony_ci * @atomicservice 39361847f8eSopenharmony_ci * @since 11 39461847f8eSopenharmony_ci */ 39561847f8eSopenharmony_ci export interface WebSocket { 39661847f8eSopenharmony_ci /** 39761847f8eSopenharmony_ci * Initiates a WebSocket request to establish a WebSocket connection to a given URL. 39861847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 39961847f8eSopenharmony_ci * @param { string } url - URL for establishing a WebSocket connection. 40061847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - the callback of connect. 40161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 40261847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 40361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 40461847f8eSopenharmony_ci * @since 6 40561847f8eSopenharmony_ci */ 40661847f8eSopenharmony_ci /** 40761847f8eSopenharmony_ci * Initiates a WebSocket request to establish a WebSocket connection to a given URL. 40861847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 40961847f8eSopenharmony_ci * @param { string } url URL for establishing a WebSocket connection. 41061847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - the callback of connect. 41161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 41261847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 41361847f8eSopenharmony_ci * @throws { BusinessError } 2302999 - Websocket other unknown error. 41461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 41561847f8eSopenharmony_ci * @crossplatform 41661847f8eSopenharmony_ci * @since 10 41761847f8eSopenharmony_ci */ 41861847f8eSopenharmony_ci /** 41961847f8eSopenharmony_ci * Initiates a WebSocket request to establish a WebSocket connection to a given URL. 42061847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 42161847f8eSopenharmony_ci * @param { string } url URL for establishing a WebSocket connection. 42261847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - the callback of connect. 42361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 42461847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 42561847f8eSopenharmony_ci * @throws { BusinessError } 2302999 - Websocket other unknown error. 42661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 42761847f8eSopenharmony_ci * @crossplatform 42861847f8eSopenharmony_ci * @atomicservice 42961847f8eSopenharmony_ci * @since 11 43061847f8eSopenharmony_ci */ 43161847f8eSopenharmony_ci /** 43261847f8eSopenharmony_ci * Initiates a WebSocket request to establish a WebSocket connection to a given URL. 43361847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 43461847f8eSopenharmony_ci * @param { string } url URL for establishing a WebSocket connection. 43561847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - the callback of connect. 43661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 43761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 43861847f8eSopenharmony_ci * @throws { BusinessError } 2302001 - Websocket url error. 43961847f8eSopenharmony_ci * @throws { BusinessError } 2302002 - Websocket certificate file does not exist. 44061847f8eSopenharmony_ci * @throws { BusinessError } 2302003 - Websocket connection already exists. 44161847f8eSopenharmony_ci * @throws { BusinessError } 2302999 - Websocket other unknown error. 44261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 44361847f8eSopenharmony_ci * @crossplatform 44461847f8eSopenharmony_ci * @atomicservice 44561847f8eSopenharmony_ci * @since 12 44661847f8eSopenharmony_ci */ 44761847f8eSopenharmony_ci connect(url: string, callback: AsyncCallback<boolean>): void; 44861847f8eSopenharmony_ci 44961847f8eSopenharmony_ci /** 45061847f8eSopenharmony_ci * Initiates a WebSocket request to establish a WebSocket connection to a given URL. 45161847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 45261847f8eSopenharmony_ci * @param { string } url URL for establishing a WebSocket connection. 45361847f8eSopenharmony_ci * @param { WebSocketRequestOptions } options - Optional parameters {@link WebSocketRequestOptions}. 45461847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - the callback of connect. 45561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 45661847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 45761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 45861847f8eSopenharmony_ci * @since 6 45961847f8eSopenharmony_ci */ 46061847f8eSopenharmony_ci /** 46161847f8eSopenharmony_ci * Initiates a WebSocket request to establish a WebSocket connection to a given URL. 46261847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 46361847f8eSopenharmony_ci * @param { string } url URL for establishing a WebSocket connection. 46461847f8eSopenharmony_ci * @param { WebSocketRequestOptions } options - Optional parameters {@link WebSocketRequestOptions}. 46561847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - the callback of connect. 46661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 46761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 46861847f8eSopenharmony_ci * @throws { BusinessError } 2302999 - Websocket other unknown error. 46961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 47061847f8eSopenharmony_ci * @crossplatform 47161847f8eSopenharmony_ci * @since 10 47261847f8eSopenharmony_ci */ 47361847f8eSopenharmony_ci /** 47461847f8eSopenharmony_ci * Initiates a WebSocket request to establish a WebSocket connection to a given URL. 47561847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 47661847f8eSopenharmony_ci * @param { string } url URL for establishing a WebSocket connection. 47761847f8eSopenharmony_ci * @param { WebSocketRequestOptions } options - Optional parameters {@link WebSocketRequestOptions}. 47861847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - the callback of connect. 47961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 48061847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 48161847f8eSopenharmony_ci * @throws { BusinessError } 2302999 - Websocket other unknown error. 48261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 48361847f8eSopenharmony_ci * @crossplatform 48461847f8eSopenharmony_ci * @atomicservice 48561847f8eSopenharmony_ci * @since 11 48661847f8eSopenharmony_ci */ 48761847f8eSopenharmony_ci /** 48861847f8eSopenharmony_ci * Initiates a WebSocket request to establish a WebSocket connection to a given URL. 48961847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 49061847f8eSopenharmony_ci * @param { string } url URL for establishing a WebSocket connection. 49161847f8eSopenharmony_ci * @param { WebSocketRequestOptions } options - Optional parameters {@link WebSocketRequestOptions}. 49261847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - the callback of connect. 49361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 49461847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 49561847f8eSopenharmony_ci * @throws { BusinessError } 2302001 - Websocket url error. 49661847f8eSopenharmony_ci * @throws { BusinessError } 2302002 - Websocket certificate file does not exist. 49761847f8eSopenharmony_ci * @throws { BusinessError } 2302003 - Websocket connection already exists. 49861847f8eSopenharmony_ci * @throws { BusinessError } 2302999 - Websocket other unknown error. 49961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 50061847f8eSopenharmony_ci * @crossplatform 50161847f8eSopenharmony_ci * @atomicservice 50261847f8eSopenharmony_ci * @since 12 50361847f8eSopenharmony_ci */ 50461847f8eSopenharmony_ci connect(url: string, options: WebSocketRequestOptions, callback: AsyncCallback<boolean>): void; 50561847f8eSopenharmony_ci 50661847f8eSopenharmony_ci /** 50761847f8eSopenharmony_ci * Initiates a WebSocket request to establish a WebSocket connection to a given URL. 50861847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 50961847f8eSopenharmony_ci * @param { string } url URL for establishing a WebSocket connection. 51061847f8eSopenharmony_ci * @param { WebSocketRequestOptions } options - Optional parameters {@link WebSocketRequestOptions}. 51161847f8eSopenharmony_ci * @returns { Promise<boolean> } The promise returned by the function. 51261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 51361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 51461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 51561847f8eSopenharmony_ci * @since 6 51661847f8eSopenharmony_ci */ 51761847f8eSopenharmony_ci /** 51861847f8eSopenharmony_ci * Initiates a WebSocket request to establish a WebSocket connection to a given URL. 51961847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 52061847f8eSopenharmony_ci * @param { string } url URL for establishing a WebSocket connection. 52161847f8eSopenharmony_ci * @param { WebSocketRequestOptions } options - Optional parameters {@link WebSocketRequestOptions}. 52261847f8eSopenharmony_ci * @returns { Promise<boolean> } The promise returned by the function. 52361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 52461847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 52561847f8eSopenharmony_ci * @throws { BusinessError } 2302999 - Websocket other unknown error. 52661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 52761847f8eSopenharmony_ci * @crossplatform 52861847f8eSopenharmony_ci * @since 10 52961847f8eSopenharmony_ci */ 53061847f8eSopenharmony_ci /** 53161847f8eSopenharmony_ci * Initiates a WebSocket request to establish a WebSocket connection to a given URL. 53261847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 53361847f8eSopenharmony_ci * @param { string } url URL for establishing a WebSocket connection. 53461847f8eSopenharmony_ci * @param { WebSocketRequestOptions } options - Optional parameters {@link WebSocketRequestOptions}. 53561847f8eSopenharmony_ci * @returns { Promise<boolean> } The promise returned by the function. 53661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 53761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 53861847f8eSopenharmony_ci * @throws { BusinessError } 2302999 - Websocket other unknown error. 53961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 54061847f8eSopenharmony_ci * @crossplatform 54161847f8eSopenharmony_ci * @atomicservice 54261847f8eSopenharmony_ci * @since 11 54361847f8eSopenharmony_ci */ 54461847f8eSopenharmony_ci /** 54561847f8eSopenharmony_ci * Initiates a WebSocket request to establish a WebSocket connection to a given URL. 54661847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 54761847f8eSopenharmony_ci * @param { string } url URL for establishing a WebSocket connection. 54861847f8eSopenharmony_ci * @param { WebSocketRequestOptions } options - Optional parameters {@link WebSocketRequestOptions}. 54961847f8eSopenharmony_ci * @returns { Promise<boolean> } The promise returned by the function. 55061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 55161847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 55261847f8eSopenharmony_ci * @throws { BusinessError } 2302001 - Websocket url error. 55361847f8eSopenharmony_ci * @throws { BusinessError } 2302002 - Websocket certificate file does not exist. 55461847f8eSopenharmony_ci * @throws { BusinessError } 2302003 - Websocket connection already exists. 55561847f8eSopenharmony_ci * @throws { BusinessError } 2302999 - Websocket other unknown error. 55661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 55761847f8eSopenharmony_ci * @crossplatform 55861847f8eSopenharmony_ci * @atomicservice 55961847f8eSopenharmony_ci * @since 12 56061847f8eSopenharmony_ci */ 56161847f8eSopenharmony_ci connect(url: string, options?: WebSocketRequestOptions): Promise<boolean>; 56261847f8eSopenharmony_ci 56361847f8eSopenharmony_ci /** 56461847f8eSopenharmony_ci * Sends data through a WebSocket connection. 56561847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 56661847f8eSopenharmony_ci * @param { string | ArrayBuffer } data - Data to send. It can be a string(API 6) or an ArrayBuffer(API 8). 56761847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - the callback of send. 56861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 56961847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 57061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 57161847f8eSopenharmony_ci * @since 6 57261847f8eSopenharmony_ci */ 57361847f8eSopenharmony_ci /** 57461847f8eSopenharmony_ci * Sends data through a WebSocket connection. 57561847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 57661847f8eSopenharmony_ci * @param { string | ArrayBuffer } data - Data to send. It can be a string(API 6) or an ArrayBuffer(API 8). 57761847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - the callback of send. 57861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 57961847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 58061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 58161847f8eSopenharmony_ci * @crossplatform 58261847f8eSopenharmony_ci * @since 10 58361847f8eSopenharmony_ci */ 58461847f8eSopenharmony_ci /** 58561847f8eSopenharmony_ci * Sends data through a WebSocket connection. 58661847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 58761847f8eSopenharmony_ci * @param { string | ArrayBuffer } data - Data to send. It can be a string(API 6) or an ArrayBuffer(API 8). 58861847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - the callback of send. 58961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 59061847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 59161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 59261847f8eSopenharmony_ci * @crossplatform 59361847f8eSopenharmony_ci * @atomicservice 59461847f8eSopenharmony_ci * @since 11 59561847f8eSopenharmony_ci */ 59661847f8eSopenharmony_ci send(data: string | ArrayBuffer, callback: AsyncCallback<boolean>): void; 59761847f8eSopenharmony_ci 59861847f8eSopenharmony_ci /** 59961847f8eSopenharmony_ci * Sends data through a WebSocket connection. 60061847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 60161847f8eSopenharmony_ci * @param { string | ArrayBuffer } data - Data to send. It can be a string(API 6) or an ArrayBuffer(API 8). 60261847f8eSopenharmony_ci * @returns { Promise<boolean> } The promise returned by the function. 60361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 60461847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 60561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 60661847f8eSopenharmony_ci * @since 6 60761847f8eSopenharmony_ci */ 60861847f8eSopenharmony_ci /** 60961847f8eSopenharmony_ci * Sends data through a WebSocket connection. 61061847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 61161847f8eSopenharmony_ci * @param { string | ArrayBuffer } data - Data to send. It can be a string(API 6) or an ArrayBuffer(API 8). 61261847f8eSopenharmony_ci * @returns { Promise<boolean> } The promise returned by the function. 61361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 61461847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 61561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 61661847f8eSopenharmony_ci * @crossplatform 61761847f8eSopenharmony_ci * @since 10 61861847f8eSopenharmony_ci */ 61961847f8eSopenharmony_ci /** 62061847f8eSopenharmony_ci * Sends data through a WebSocket connection. 62161847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 62261847f8eSopenharmony_ci * @param { string | ArrayBuffer } data - Data to send. It can be a string(API 6) or an ArrayBuffer(API 8). 62361847f8eSopenharmony_ci * @returns { Promise<boolean> } The promise returned by the function. 62461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 62561847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 62661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 62761847f8eSopenharmony_ci * @crossplatform 62861847f8eSopenharmony_ci * @atomicservice 62961847f8eSopenharmony_ci * @since 11 63061847f8eSopenharmony_ci */ 63161847f8eSopenharmony_ci send(data: string | ArrayBuffer): Promise<boolean>; 63261847f8eSopenharmony_ci 63361847f8eSopenharmony_ci /** 63461847f8eSopenharmony_ci * Closes a WebSocket connection. 63561847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 63661847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - the callback of close. 63761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 63861847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 63961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 64061847f8eSopenharmony_ci * @since 6 64161847f8eSopenharmony_ci */ 64261847f8eSopenharmony_ci /** 64361847f8eSopenharmony_ci * Closes a WebSocket connection. 64461847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 64561847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - the callback of close. 64661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 64761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 64861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 64961847f8eSopenharmony_ci * @crossplatform 65061847f8eSopenharmony_ci * @since 10 65161847f8eSopenharmony_ci */ 65261847f8eSopenharmony_ci /** 65361847f8eSopenharmony_ci * Closes a WebSocket connection. 65461847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 65561847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - the callback of close. 65661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 65761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 65861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 65961847f8eSopenharmony_ci * @crossplatform 66061847f8eSopenharmony_ci * @atomicservice 66161847f8eSopenharmony_ci * @since 11 66261847f8eSopenharmony_ci */ 66361847f8eSopenharmony_ci close(callback: AsyncCallback<boolean>): void; 66461847f8eSopenharmony_ci 66561847f8eSopenharmony_ci /** 66661847f8eSopenharmony_ci * Closes a WebSocket connection. 66761847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 66861847f8eSopenharmony_ci * @param { WebSocketCloseOptions } options - Optional parameters {@link WebSocketCloseOptions}. 66961847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - the callback of close. 67061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 67161847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 67261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 67361847f8eSopenharmony_ci * @since 6 67461847f8eSopenharmony_ci */ 67561847f8eSopenharmony_ci /** 67661847f8eSopenharmony_ci * Closes a WebSocket connection. 67761847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 67861847f8eSopenharmony_ci * @param { WebSocketCloseOptions } options - Optional parameters {@link WebSocketCloseOptions}. 67961847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - the callback of close. 68061847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 68161847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 68261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 68361847f8eSopenharmony_ci * @crossplatform 68461847f8eSopenharmony_ci * @since 10 68561847f8eSopenharmony_ci */ 68661847f8eSopenharmony_ci /** 68761847f8eSopenharmony_ci * Closes a WebSocket connection. 68861847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 68961847f8eSopenharmony_ci * @param { WebSocketCloseOptions } options - Optional parameters {@link WebSocketCloseOptions}. 69061847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - the callback of close. 69161847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 69261847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 69361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 69461847f8eSopenharmony_ci * @crossplatform 69561847f8eSopenharmony_ci * @atomicservice 69661847f8eSopenharmony_ci * @since 11 69761847f8eSopenharmony_ci */ 69861847f8eSopenharmony_ci close(options: WebSocketCloseOptions, callback: AsyncCallback<boolean>): void; 69961847f8eSopenharmony_ci 70061847f8eSopenharmony_ci /** 70161847f8eSopenharmony_ci * Closes a WebSocket connection. 70261847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 70361847f8eSopenharmony_ci * @param { WebSocketCloseOptions } options - Optional parameters {@link WebSocketCloseOptions}. 70461847f8eSopenharmony_ci * @returns { Promise<boolean> } The promise returned by the function. 70561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 70661847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 70761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 70861847f8eSopenharmony_ci * @since 6 70961847f8eSopenharmony_ci */ 71061847f8eSopenharmony_ci /** 71161847f8eSopenharmony_ci * Closes a WebSocket connection. 71261847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 71361847f8eSopenharmony_ci * @param { WebSocketCloseOptions } options - Optional parameters {@link WebSocketCloseOptions}. 71461847f8eSopenharmony_ci * @returns { Promise<boolean> } The promise returned by the function. 71561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 71661847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 71761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 71861847f8eSopenharmony_ci * @crossplatform 71961847f8eSopenharmony_ci * @since 10 72061847f8eSopenharmony_ci */ 72161847f8eSopenharmony_ci /** 72261847f8eSopenharmony_ci * Closes a WebSocket connection. 72361847f8eSopenharmony_ci * @permission ohos.permission.INTERNET 72461847f8eSopenharmony_ci * @param { WebSocketCloseOptions } options - Optional parameters {@link WebSocketCloseOptions}. 72561847f8eSopenharmony_ci * @returns { Promise<boolean> } The promise returned by the function. 72661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. 72761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 72861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 72961847f8eSopenharmony_ci * @crossplatform 73061847f8eSopenharmony_ci * @atomicservice 73161847f8eSopenharmony_ci * @since 11 73261847f8eSopenharmony_ci */ 73361847f8eSopenharmony_ci close(options?: WebSocketCloseOptions): Promise<boolean>; 73461847f8eSopenharmony_ci 73561847f8eSopenharmony_ci /** 73661847f8eSopenharmony_ci * Enables listening for the open events of a WebSocket connection. 73761847f8eSopenharmony_ci * @param { 'open' } type - event indicating that a WebSocket connection has been opened. 73861847f8eSopenharmony_ci * @param { AsyncCallback<Object> } callback - the callback used to return the result. 73961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 74061847f8eSopenharmony_ci * @since 6 74161847f8eSopenharmony_ci */ 74261847f8eSopenharmony_ci /** 74361847f8eSopenharmony_ci * Enables listening for the open events of a WebSocket connection. 74461847f8eSopenharmony_ci * @param { 'open' } type - event indicating that a WebSocket connection has been opened. 74561847f8eSopenharmony_ci * @param { AsyncCallback<Object> } callback - the callback used to return the result. 74661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 74761847f8eSopenharmony_ci * @crossplatform 74861847f8eSopenharmony_ci * @since 10 74961847f8eSopenharmony_ci */ 75061847f8eSopenharmony_ci /** 75161847f8eSopenharmony_ci * Enables listening for the open events of a WebSocket connection. 75261847f8eSopenharmony_ci * @param { 'open' } type - event indicating that a WebSocket connection has been opened. 75361847f8eSopenharmony_ci * @param { AsyncCallback<Object> } callback - the callback used to return the result. 75461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 75561847f8eSopenharmony_ci * @crossplatform 75661847f8eSopenharmony_ci * @atomicservice 75761847f8eSopenharmony_ci * @since 11 75861847f8eSopenharmony_ci */ 75961847f8eSopenharmony_ci on(type: 'open', callback: AsyncCallback<Object>): void; 76061847f8eSopenharmony_ci 76161847f8eSopenharmony_ci /** 76261847f8eSopenharmony_ci * Cancels listening for the open events of a WebSocket connection. 76361847f8eSopenharmony_ci * @param { 'open' } type - event indicating that a WebSocket connection has been opened. 76461847f8eSopenharmony_ci * @param { AsyncCallback<Object> } callback - the callback used to return the result. 76561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 76661847f8eSopenharmony_ci * @since 6 76761847f8eSopenharmony_ci */ 76861847f8eSopenharmony_ci /** 76961847f8eSopenharmony_ci * Cancels listening for the open events of a WebSocket connection. 77061847f8eSopenharmony_ci * @param { 'open' } type - event indicating that a WebSocket connection has been opened. 77161847f8eSopenharmony_ci * @param { AsyncCallback<Object> } callback the callback used to return the result. 77261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 77361847f8eSopenharmony_ci * @crossplatform 77461847f8eSopenharmony_ci * @since 10 77561847f8eSopenharmony_ci */ 77661847f8eSopenharmony_ci /** 77761847f8eSopenharmony_ci * Cancels listening for the open events of a WebSocket connection. 77861847f8eSopenharmony_ci * @param { 'open' } type - event indicating that a WebSocket connection has been opened. 77961847f8eSopenharmony_ci * @param { AsyncCallback<Object> } callback the callback used to return the result. 78061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 78161847f8eSopenharmony_ci * @crossplatform 78261847f8eSopenharmony_ci * @atomicservice 78361847f8eSopenharmony_ci * @since 11 78461847f8eSopenharmony_ci */ 78561847f8eSopenharmony_ci off(type: 'open', callback?: AsyncCallback<Object>): void; 78661847f8eSopenharmony_ci 78761847f8eSopenharmony_ci /** 78861847f8eSopenharmony_ci * Enables listening for the message events of a WebSocket connection. 78961847f8eSopenharmony_ci * data in AsyncCallback can be a string(API 6) or an ArrayBuffer(API 8). 79061847f8eSopenharmony_ci * @param { 'message' } type - event indicating that a message has been received from the server. 79161847f8eSopenharmony_ci * @param { AsyncCallback<string | ArrayBuffer> } callback - the callback used to return the result. 79261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 79361847f8eSopenharmony_ci * @since 6 79461847f8eSopenharmony_ci */ 79561847f8eSopenharmony_ci /** 79661847f8eSopenharmony_ci * Enables listening for the message events of a WebSocket connection. 79761847f8eSopenharmony_ci * data in AsyncCallback can be a string(API 6) or an ArrayBuffer(API 8). 79861847f8eSopenharmony_ci * @param { 'message' } type - event indicating that a message has been received from the server. 79961847f8eSopenharmony_ci * @param { AsyncCallback<string | ArrayBuffer> } callback - the callback used to return the result. 80061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 80161847f8eSopenharmony_ci * @crossplatform 80261847f8eSopenharmony_ci * @since 10 80361847f8eSopenharmony_ci */ 80461847f8eSopenharmony_ci /** 80561847f8eSopenharmony_ci * Enables listening for the message events of a WebSocket connection. 80661847f8eSopenharmony_ci * data in AsyncCallback can be a string(API 6) or an ArrayBuffer(API 8). 80761847f8eSopenharmony_ci * @param { 'message' } type - event indicating that a message has been received from the server. 80861847f8eSopenharmony_ci * @param { AsyncCallback<string | ArrayBuffer> } callback - the callback used to return the result. 80961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 81061847f8eSopenharmony_ci * @crossplatform 81161847f8eSopenharmony_ci * @atomicservice 81261847f8eSopenharmony_ci * @since 11 81361847f8eSopenharmony_ci */ 81461847f8eSopenharmony_ci on(type: 'message', callback: AsyncCallback<string | ArrayBuffer>): void; 81561847f8eSopenharmony_ci 81661847f8eSopenharmony_ci /** 81761847f8eSopenharmony_ci * Cancels listening for the message events of a WebSocket connection. 81861847f8eSopenharmony_ci * data in AsyncCallback can be a string(API 6) or an ArrayBuffer(API 8). 81961847f8eSopenharmony_ci * @param { 'message' } type - event indicating that a message has been received from the server. 82061847f8eSopenharmony_ci * @param { AsyncCallback<string | ArrayBuffer> } callback - the callback used to return the result. 82161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 82261847f8eSopenharmony_ci * @since 6 82361847f8eSopenharmony_ci */ 82461847f8eSopenharmony_ci /** 82561847f8eSopenharmony_ci * Cancels listening for the message events of a WebSocket connection. 82661847f8eSopenharmony_ci * data in AsyncCallback can be a string(API 6) or an ArrayBuffer(API 8). 82761847f8eSopenharmony_ci * @param { 'message' } type - event indicating that a message has been received from the server. 82861847f8eSopenharmony_ci * @param { AsyncCallback<string | ArrayBuffer> } callback - the callback used to return the result. 82961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 83061847f8eSopenharmony_ci * @crossplatform 83161847f8eSopenharmony_ci * @since 10 83261847f8eSopenharmony_ci */ 83361847f8eSopenharmony_ci /** 83461847f8eSopenharmony_ci * Cancels listening for the message events of a WebSocket connection. 83561847f8eSopenharmony_ci * data in AsyncCallback can be a string(API 6) or an ArrayBuffer(API 8). 83661847f8eSopenharmony_ci * @param { 'message' } type - event indicating that a message has been received from the server. 83761847f8eSopenharmony_ci * @param { AsyncCallback<string | ArrayBuffer> } callback - the callback used to return the result. 83861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 83961847f8eSopenharmony_ci * @crossplatform 84061847f8eSopenharmony_ci * @atomicservice 84161847f8eSopenharmony_ci * @since 11 84261847f8eSopenharmony_ci */ 84361847f8eSopenharmony_ci off(type: 'message', callback?: AsyncCallback<string | ArrayBuffer>): void; 84461847f8eSopenharmony_ci 84561847f8eSopenharmony_ci /** 84661847f8eSopenharmony_ci * Enables listening for the close events of a WebSocket connection. 84761847f8eSopenharmony_ci * @param { 'close' } type - event indicating that a WebSocket connection has been closed. 84861847f8eSopenharmony_ci * @param { AsyncCallback<CloseResult> } callback - the callback used to return the result. 84961847f8eSopenharmony_ci * <br>close indicates the close error code and reason indicates the error code description. 85061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 85161847f8eSopenharmony_ci * @since 6 85261847f8eSopenharmony_ci */ 85361847f8eSopenharmony_ci /** 85461847f8eSopenharmony_ci * Enables listening for the close events of a WebSocket connection. 85561847f8eSopenharmony_ci * @param { 'close' } type - event indicating that a WebSocket connection has been closed. 85661847f8eSopenharmony_ci * @param { AsyncCallback<CloseResult> } callback - the callback used to return the result. 85761847f8eSopenharmony_ci * <br>close indicates the close error code and reason indicates the error code description. 85861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 85961847f8eSopenharmony_ci * @crossplatform 86061847f8eSopenharmony_ci * @since 10 86161847f8eSopenharmony_ci */ 86261847f8eSopenharmony_ci /** 86361847f8eSopenharmony_ci * Enables listening for the close events of a WebSocket connection. 86461847f8eSopenharmony_ci * @param { 'close' } type - event indicating that a WebSocket connection has been closed. 86561847f8eSopenharmony_ci * @param { AsyncCallback<CloseResult> } callback - the callback used to return the result. 86661847f8eSopenharmony_ci * <br>close indicates the close error code and reason indicates the error code description. 86761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 86861847f8eSopenharmony_ci * @crossplatform 86961847f8eSopenharmony_ci * @atomicservice 87061847f8eSopenharmony_ci * @since 11 87161847f8eSopenharmony_ci */ 87261847f8eSopenharmony_ci on(type: 'close', callback: AsyncCallback<CloseResult>): void; 87361847f8eSopenharmony_ci 87461847f8eSopenharmony_ci /** 87561847f8eSopenharmony_ci * Cancels listening for the close events of a WebSocket connection. 87661847f8eSopenharmony_ci * @param { 'close' } type - event indicating that a WebSocket connection has been closed. 87761847f8eSopenharmony_ci * @param { AsyncCallback<CloseResult> } callback - the callback used to return the result. 87861847f8eSopenharmony_ci * <br>close indicates the close error code and reason indicates the error code description. 87961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 88061847f8eSopenharmony_ci * @since 6 88161847f8eSopenharmony_ci */ 88261847f8eSopenharmony_ci /** 88361847f8eSopenharmony_ci * Cancels listening for the close events of a WebSocket connection. 88461847f8eSopenharmony_ci * @param { 'close' } type - event indicating that a WebSocket connection has been closed. 88561847f8eSopenharmony_ci * @param { AsyncCallback<CloseResult> } callback - the callback used to return the result. 88661847f8eSopenharmony_ci * <br>close indicates the close error code and reason indicates the error code description. 88761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 88861847f8eSopenharmony_ci * @crossplatform 88961847f8eSopenharmony_ci * @since 10 89061847f8eSopenharmony_ci */ 89161847f8eSopenharmony_ci /** 89261847f8eSopenharmony_ci * Cancels listening for the close events of a WebSocket connection. 89361847f8eSopenharmony_ci * @param { 'close' } type - event indicating that a WebSocket connection has been closed. 89461847f8eSopenharmony_ci * @param { AsyncCallback<CloseResult> } callback - the callback used to return the result. 89561847f8eSopenharmony_ci * <br>close indicates the close error code and reason indicates the error code description. 89661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 89761847f8eSopenharmony_ci * @crossplatform 89861847f8eSopenharmony_ci * @atomicservice 89961847f8eSopenharmony_ci * @since 11 90061847f8eSopenharmony_ci */ 90161847f8eSopenharmony_ci off(type: 'close', callback?: AsyncCallback<CloseResult>): void; 90261847f8eSopenharmony_ci 90361847f8eSopenharmony_ci /** 90461847f8eSopenharmony_ci * Enables listening for the error events of a WebSocket connection. 90561847f8eSopenharmony_ci * @param { 'error' } type - event indicating the WebSocket connection has encountered an error. 90661847f8eSopenharmony_ci * @param { ErrorCallback } callback - the callback used to return the result. 90761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 90861847f8eSopenharmony_ci * @since 6 90961847f8eSopenharmony_ci */ 91061847f8eSopenharmony_ci /** 91161847f8eSopenharmony_ci * Enables listening for the error events of a WebSocket connection. 91261847f8eSopenharmony_ci * @param { 'error' } type - event indicating the WebSocket connection has encountered an error. 91361847f8eSopenharmony_ci * @param { ErrorCallback } callback - the callback used to return the result. 91461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 91561847f8eSopenharmony_ci * @crossplatform 91661847f8eSopenharmony_ci * @since 10 91761847f8eSopenharmony_ci */ 91861847f8eSopenharmony_ci /** 91961847f8eSopenharmony_ci * Enables listening for the error events of a WebSocket connection. 92061847f8eSopenharmony_ci * @param { 'error' } type - event indicating the WebSocket connection has encountered an error. 92161847f8eSopenharmony_ci * @param { ErrorCallback } callback - the callback used to return the result. 92261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 92361847f8eSopenharmony_ci * @crossplatform 92461847f8eSopenharmony_ci * @atomicservice 92561847f8eSopenharmony_ci * @since 11 92661847f8eSopenharmony_ci */ 92761847f8eSopenharmony_ci on(type: 'error', callback: ErrorCallback): void; 92861847f8eSopenharmony_ci 92961847f8eSopenharmony_ci /** 93061847f8eSopenharmony_ci * Cancels listening for the error events of a WebSocket connection. 93161847f8eSopenharmony_ci * @param { 'error' } type - event indicating the WebSocket connection has encountered an error. 93261847f8eSopenharmony_ci * @param { ErrorCallback } callback - the callback used to return the result. 93361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 93461847f8eSopenharmony_ci * @since 6 93561847f8eSopenharmony_ci */ 93661847f8eSopenharmony_ci /** 93761847f8eSopenharmony_ci * Cancels listening for the error events of a WebSocket connection. 93861847f8eSopenharmony_ci * @param { 'error' } type - event indicating the WebSocket connection has encountered an error. 93961847f8eSopenharmony_ci * @param { ErrorCallback } callback - the callback used to return the result. 94061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 94161847f8eSopenharmony_ci * @crossplatform 94261847f8eSopenharmony_ci * @since 10 94361847f8eSopenharmony_ci */ 94461847f8eSopenharmony_ci /** 94561847f8eSopenharmony_ci * Cancels listening for the error events of a WebSocket connection. 94661847f8eSopenharmony_ci * @param { 'error' } type - event indicating the WebSocket connection has encountered an error. 94761847f8eSopenharmony_ci * @param { ErrorCallback } callback - the callback used to return the result. 94861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 94961847f8eSopenharmony_ci * @crossplatform 95061847f8eSopenharmony_ci * @atomicservice 95161847f8eSopenharmony_ci * @since 11 95261847f8eSopenharmony_ci */ 95361847f8eSopenharmony_ci off(type: 'error', callback?: ErrorCallback): void; 95461847f8eSopenharmony_ci 95561847f8eSopenharmony_ci /** 95661847f8eSopenharmony_ci * Enables listening for receiving data ends events of a WebSocket connection. 95761847f8eSopenharmony_ci * @param { 'dataEnd' } type - event indicating the WebSocket connection has received data ends. 95861847f8eSopenharmony_ci * @param { Callback<void> } callback - the callback used to return the result. 95961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 96061847f8eSopenharmony_ci * @since 11 96161847f8eSopenharmony_ci */ 96261847f8eSopenharmony_ci /** 96361847f8eSopenharmony_ci * Enables listening for receiving data ends events of a WebSocket connection. 96461847f8eSopenharmony_ci * @param { 'dataEnd' } type - event indicating the WebSocket connection has received data ends. 96561847f8eSopenharmony_ci * @param { Callback<void> } callback - the callback used to return the result. 96661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 96761847f8eSopenharmony_ci * @crossplatform 96861847f8eSopenharmony_ci * @since 12 96961847f8eSopenharmony_ci */ 97061847f8eSopenharmony_ci on(type: 'dataEnd', callback: Callback<void>): void; 97161847f8eSopenharmony_ci 97261847f8eSopenharmony_ci /** 97361847f8eSopenharmony_ci * Cancels listening for receiving data ends events of a WebSocket connection. 97461847f8eSopenharmony_ci * @param { 'dataEnd' } type - event indicating the WebSocket connection has received data ends. 97561847f8eSopenharmony_ci * @param { Callback<void> } [ callback ] - the callback used to return the result. 97661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 97761847f8eSopenharmony_ci * @since 11 97861847f8eSopenharmony_ci */ 97961847f8eSopenharmony_ci /** 98061847f8eSopenharmony_ci * Cancels listening for receiving data ends events of a WebSocket connection. 98161847f8eSopenharmony_ci * @param { 'dataEnd' } type - event indicating the WebSocket connection has received data ends. 98261847f8eSopenharmony_ci * @param { Callback<void> } [ callback ] - the callback used to return the result. 98361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 98461847f8eSopenharmony_ci * @crossplatform 98561847f8eSopenharmony_ci * @since 12 98661847f8eSopenharmony_ci */ 98761847f8eSopenharmony_ci off(type: 'dataEnd', callback?: Callback<void>): void; 98861847f8eSopenharmony_ci 98961847f8eSopenharmony_ci /** 99061847f8eSopenharmony_ci * Registers an observer for HTTP Response Header events. 99161847f8eSopenharmony_ci * @param { 'headerReceive'} type - Indicates Event name. 99261847f8eSopenharmony_ci * @param { Callback<ResponseHeaders> } callback - the callback used to return the result. 99361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 99461847f8eSopenharmony_ci * @since 12 99561847f8eSopenharmony_ci */ 99661847f8eSopenharmony_ci on(type: 'headerReceive', callback: Callback<ResponseHeaders>): void; 99761847f8eSopenharmony_ci 99861847f8eSopenharmony_ci /** 99961847f8eSopenharmony_ci * Unregisters the observer for HTTP Response Header events. 100061847f8eSopenharmony_ci * @param { 'headerReceive' } type - Indicates Event name. 100161847f8eSopenharmony_ci * @param { Callback<ResponseHeaders> } [callback] - the callback used to return the result. 100261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack 100361847f8eSopenharmony_ci * @since 12 100461847f8eSopenharmony_ci */ 100561847f8eSopenharmony_ci off(type: 'headerReceive', callback?: Callback<ResponseHeaders>): void; 100661847f8eSopenharmony_ci } 100761847f8eSopenharmony_ci} 100861847f8eSopenharmony_ci 100961847f8eSopenharmony_ciexport default webSocket;