mirror of
https://gitee.com/openharmony/interface_sdk-js
synced 2024-10-07 22:24:20 +00:00
FIX:网络管理netstack仓跨平台接口规范
Signed-off-by: Yangys <yangyousheng@huawei.com> Change-Id: I22c9ae52d5be218fbb9a219603370178854b2ec3
This commit is contained in:
parent
fc11a8f24d
commit
a1954ebcfc
699
api/@ohos.net.http.d.ts
vendored
699
api/@ohos.net.http.d.ts
vendored
File diff suppressed because it is too large
Load Diff
1190
api/@ohos.net.socket.d.ts
vendored
1190
api/@ohos.net.socket.d.ts
vendored
File diff suppressed because it is too large
Load Diff
243
api/@ohos.net.webSocket.d.ts
vendored
243
api/@ohos.net.webSocket.d.ts
vendored
@ -21,31 +21,56 @@ import { AsyncCallback, ErrorCallback } from "./@ohos.base";
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* Provides WebSocket APIs.
|
||||
* @namespace webSocket
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 10
|
||||
*/
|
||||
declare namespace webSocket {
|
||||
/**
|
||||
* Creates a web socket connection.
|
||||
* @returns { WebSocket } the WebSocket of the createWebSocket.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* Creates a web socket connection.
|
||||
* @returns { WebSocket } the WebSocket of the createWebSocket.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 10
|
||||
*/
|
||||
function createWebSocket(): WebSocket;
|
||||
|
||||
/**
|
||||
* Defines the optional parameters carried in the request for establishing a WebSocket connection.
|
||||
* @interface WebSocketRequestOptions
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* Defines the optional parameters carried in the request for establishing a WebSocket connection.
|
||||
* @interface WebSocketRequestOptions
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 10
|
||||
*/
|
||||
export interface WebSocketRequestOptions {
|
||||
/**
|
||||
* HTTP request header.
|
||||
* @type {?Object}
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* HTTP request header.
|
||||
* @type {?Object}
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 10
|
||||
*/
|
||||
header?: Object;
|
||||
}
|
||||
|
||||
@ -53,35 +78,60 @@ declare namespace webSocket {
|
||||
* Defines the optional parameters carried in the request for closing a WebSocket connection.
|
||||
* @interface WebSocketCloseOptions
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* Defines the optional parameters carried in the request for closing a WebSocket connection.
|
||||
* @interface WebSocketCloseOptions
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 10
|
||||
*/
|
||||
export interface WebSocketCloseOptions {
|
||||
/**
|
||||
* Error code.
|
||||
* @type {?number}
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* Error code.
|
||||
* @type {?number}
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 10
|
||||
*/
|
||||
code?: number;
|
||||
/**
|
||||
* Error cause.
|
||||
* @type {?string}
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* Error cause.
|
||||
* @type {?string}
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 10
|
||||
*/
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Defines a WebSocket object. Before invoking WebSocket APIs,
|
||||
* <p>Defines a WebSocket object. Before invoking WebSocket APIs,
|
||||
* you need to call webSocket.createWebSocket to create a WebSocket object.</p>
|
||||
* @interface WebSocket
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* <p>Defines a WebSocket object. Before invoking WebSocket APIs,
|
||||
* you need to call webSocket.createWebSocket to create a WebSocket object.</p>
|
||||
* @interface WebSocket
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
* @since 10
|
||||
*/
|
||||
export interface WebSocket {
|
||||
/**
|
||||
@ -92,9 +142,19 @@ declare namespace webSocket {
|
||||
* @throws { BusinessError } 401 - Parameter error.
|
||||
* @throws { BusinessError } 201 - Permission denied.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* Initiates a WebSocket request to establish a WebSocket connection to a given URL.
|
||||
* @permission ohos.permission.INTERNET
|
||||
* @param { string } url URL for establishing a WebSocket connection.
|
||||
* @param { AsyncCallback<boolean> } callback Returns callback used to return the execution result.
|
||||
* @throws { BusinessError } 401 - Parameter error.
|
||||
* @throws { BusinessError } 201 - Permission denied.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 10
|
||||
*/
|
||||
connect(url: string, callback: AsyncCallback<boolean>): void;
|
||||
|
||||
/**
|
||||
@ -106,9 +166,20 @@ declare namespace webSocket {
|
||||
* @throws { BusinessError } 401 - Parameter error.
|
||||
* @throws { BusinessError } 201 - Permission denied.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* Initiates a WebSocket request to establish a WebSocket connection to a given URL.
|
||||
* @permission ohos.permission.INTERNET
|
||||
* @param { string } url URL for establishing a WebSocket connection.
|
||||
* @param { WebSocketRequestOptions } options Optional parameters {@link WebSocketRequestOptions}.
|
||||
* @param { AsyncCallback<boolean> } callback Returns callback used to return the execution result.
|
||||
* @throws { BusinessError } 401 - Parameter error.
|
||||
* @throws { BusinessError } 201 - Permission denied.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 10
|
||||
*/
|
||||
connect(url: string, options: WebSocketRequestOptions, callback: AsyncCallback<boolean>): void;
|
||||
|
||||
/**
|
||||
@ -120,9 +191,20 @@ declare namespace webSocket {
|
||||
* @throws { BusinessError } 401 - Parameter error.
|
||||
* @throws { BusinessError } 201 - Permission denied.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* Initiates a WebSocket request to establish a WebSocket connection to a given URL.
|
||||
* @permission ohos.permission.INTERNET
|
||||
* @param { string } url URL for establishing a WebSocket connection.
|
||||
* @param { WebSocketRequestOptions } options Optional parameters {@link WebSocketRequestOptions}.
|
||||
* @returns { Promise<boolean> } The promise returned by the function.
|
||||
* @throws { BusinessError } 401 - Parameter error.
|
||||
* @throws { BusinessError } 201 - Permission denied.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 10
|
||||
*/
|
||||
connect(url: string, options?: WebSocketRequestOptions): Promise<boolean>;
|
||||
|
||||
/**
|
||||
@ -133,9 +215,19 @@ declare namespace webSocket {
|
||||
* @throws { BusinessError } 401 - Parameter error.
|
||||
* @throws { BusinessError } 201 - Permission denied.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* Sends data through a WebSocket connection.
|
||||
* @permission ohos.permission.INTERNET
|
||||
* @param { string | ArrayBuffer } data Data to send. It can be a string(API 6) or an ArrayBuffer(API 8).
|
||||
* @param { AsyncCallback<boolean> } callback Returns callback used to return the execution result.
|
||||
* @throws { BusinessError } 401 - Parameter error.
|
||||
* @throws { BusinessError } 201 - Permission denied.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 10
|
||||
*/
|
||||
send(data: string | ArrayBuffer, callback: AsyncCallback<boolean>): void;
|
||||
|
||||
/**
|
||||
@ -146,9 +238,19 @@ declare namespace webSocket {
|
||||
* @throws { BusinessError } 401 - Parameter error.
|
||||
* @throws { BusinessError } 201 - Permission denied.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* Sends data through a WebSocket connection.
|
||||
* @permission ohos.permission.INTERNET
|
||||
* @param { string | ArrayBuffer } data Data to send. It can be a string(API 6) or an ArrayBuffer(API 8).
|
||||
* @returns { Promise<boolean> } The promise returned by the function.
|
||||
* @throws { BusinessError } 401 - Parameter error.
|
||||
* @throws { BusinessError } 201 - Permission denied.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 10
|
||||
*/
|
||||
send(data: string | ArrayBuffer): Promise<boolean>;
|
||||
|
||||
/**
|
||||
@ -158,9 +260,18 @@ declare namespace webSocket {
|
||||
* @throws { BusinessError } 401 - Parameter error.
|
||||
* @throws { BusinessError } 201 - Permission denied.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* Closes a WebSocket connection.
|
||||
* @permission ohos.permission.INTERNET
|
||||
* @param { AsyncCallback<boolean> } callback Returns callback used to return the execution result.
|
||||
* @throws { BusinessError } 401 - Parameter error.
|
||||
* @throws { BusinessError } 201 - Permission denied.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 10
|
||||
*/
|
||||
close(callback: AsyncCallback<boolean>): void;
|
||||
|
||||
/**
|
||||
@ -171,9 +282,19 @@ declare namespace webSocket {
|
||||
* @throws { BusinessError } 401 - Parameter error.
|
||||
* @throws { BusinessError } 201 - Permission denied.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* Closes a WebSocket connection.
|
||||
* @permission ohos.permission.INTERNET
|
||||
* @param { WebSocketCloseOptions } options Optional parameters {@link WebSocketCloseOptions}.
|
||||
* @param { AsyncCallback<boolean> } callback Returns callback used to return the execution result.
|
||||
* @throws { BusinessError } 401 - Parameter error.
|
||||
* @throws { BusinessError } 201 - Permission denied.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 10
|
||||
*/
|
||||
close(options: WebSocketCloseOptions, callback: AsyncCallback<boolean>): void;
|
||||
|
||||
/**
|
||||
@ -184,28 +305,52 @@ declare namespace webSocket {
|
||||
* @throws { BusinessError } 401 - Parameter error.
|
||||
* @throws { BusinessError } 201 - Permission denied.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* Closes a WebSocket connection.
|
||||
* @permission ohos.permission.INTERNET
|
||||
* @param { WebSocketCloseOptions } options Optional parameters {@link WebSocketCloseOptions}.
|
||||
* @returns { Promise<boolean> } The promise returned by the function.
|
||||
* @throws { BusinessError } 401 - Parameter error.
|
||||
* @throws { BusinessError } 201 - Permission denied.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 10
|
||||
*/
|
||||
close(options?: WebSocketCloseOptions): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Enables listening for the open events of a WebSocket connection.
|
||||
* @param { 'open' } type event indicating that a WebSocket connection has been opened.
|
||||
* @param { 'open' } type event indicating that a WebSocket connection has been opened.
|
||||
* @param { AsyncCallback<Object> } callback Returns callback used to return the result.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* Enables listening for the open events of a WebSocket connection.
|
||||
* @param { 'open' } type event indicating that a WebSocket connection has been opened.
|
||||
* @param { AsyncCallback<Object> } callback Returns callback used to return the result.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
* @since 10
|
||||
*/
|
||||
on(type: 'open', callback: AsyncCallback<Object>): void;
|
||||
|
||||
/**
|
||||
* Cancels listening for the open events of a WebSocket connection.
|
||||
* @param { 'open' } type event indicating that a WebSocket connection has been opened.
|
||||
* @param { 'open' } type event indicating that a WebSocket connection has been opened.
|
||||
* @param { AsyncCallback<Object> } callback Returns callback used to return the result.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* Cancels listening for the open events of a WebSocket connection.
|
||||
* @param { 'open' } type event indicating that a WebSocket connection has been opened.
|
||||
* @param { AsyncCallback<Object> } callback Returns callback used to return the result.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
* @since 10
|
||||
*/
|
||||
off(type: 'open', callback?: AsyncCallback<Object>): void;
|
||||
|
||||
@ -215,9 +360,17 @@ declare namespace webSocket {
|
||||
* @param { 'message' } type event indicating that a message has been received from the server.
|
||||
* @param { AsyncCallback<string | ArrayBuffer> } callback Returns callback used to return the result.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* Enables listening for the message events of a WebSocket connection.
|
||||
* data in AsyncCallback can be a string(API 6) or an ArrayBuffer(API 8).
|
||||
* @param { 'message' } type event indicating that a message has been received from the server.
|
||||
* @param { AsyncCallback<string | ArrayBuffer> } callback Returns callback used to return the result.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 10
|
||||
*/
|
||||
on(type: 'message', callback: AsyncCallback<string | ArrayBuffer>): void;
|
||||
|
||||
/**
|
||||
@ -226,9 +379,17 @@ declare namespace webSocket {
|
||||
* @param { 'message' } type event indicating that a message has been received from the server.
|
||||
* @param { AsyncCallback<string | ArrayBuffer> } callback Returns callback used to return the result.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* Cancels listening for the message events of a WebSocket connection.
|
||||
* data in AsyncCallback can be a string(API 6) or an ArrayBuffer(API 8).
|
||||
* @param { 'message' } type event indicating that a message has been received from the server.
|
||||
* @param { AsyncCallback<string | ArrayBuffer> } callback Returns callback used to return the result.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 10
|
||||
*/
|
||||
off(type: 'message', callback?: AsyncCallback<string | ArrayBuffer>): void;
|
||||
|
||||
/**
|
||||
@ -237,9 +398,17 @@ declare namespace webSocket {
|
||||
* @param { AsyncCallback<{ code: number, reason: string }> } callback Callback used to return the result.
|
||||
* <br>close indicates the close error code and reason indicates the error code description.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* Enables listening for the close events of a WebSocket connection.
|
||||
* @param { 'close' } type event indicating that a WebSocket connection has been closed.
|
||||
* @param { AsyncCallback<{ code: number, reason: string }> } callback Callback used to return the result.
|
||||
* <br>close indicates the close error code and reason indicates the error code description.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 10
|
||||
*/
|
||||
on(type: 'close', callback: AsyncCallback<{ code: number, reason: string }>): void;
|
||||
|
||||
/**
|
||||
@ -248,9 +417,17 @@ declare namespace webSocket {
|
||||
* @param { AsyncCallback<{ code: number, reason: string }> } callback Callback used to return the result.
|
||||
* <br>close indicates the close error code and reason indicates the error code description.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* Cancels listening for the close events of a WebSocket connection.
|
||||
* @param { 'close' } type event indicating that a WebSocket connection has been closed.
|
||||
* @param { AsyncCallback<{ code: number, reason: string }> } callback Callback used to return the result.
|
||||
* <br>close indicates the close error code and reason indicates the error code description.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 10
|
||||
*/
|
||||
off(type: 'close', callback?: AsyncCallback<{ code: number, reason: string }>): void;
|
||||
|
||||
/**
|
||||
@ -258,9 +435,16 @@ declare namespace webSocket {
|
||||
* @param { 'error' } type event indicating the WebSocket connection has encountered an error.
|
||||
* @param { ErrorCallback } callback return callback used to return the result.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* Enables listening for the error events of a WebSocket connection.
|
||||
* @param { 'error' } type event indicating the WebSocket connection has encountered an error.
|
||||
* @param { ErrorCallback } callback return callback used to return the result.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 10
|
||||
*/
|
||||
on(type: 'error', callback: ErrorCallback): void;
|
||||
|
||||
/**
|
||||
@ -268,9 +452,16 @@ declare namespace webSocket {
|
||||
* @param { 'error' } type event indicating the WebSocket connection has encountered an error.
|
||||
* @param { ErrorCallback } callback return callback used to return the result.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 6
|
||||
*/
|
||||
/**
|
||||
* Cancels listening for the error events of a WebSocket connection.
|
||||
* @param { 'error' } type event indicating the WebSocket connection has encountered an error.
|
||||
* @param { ErrorCallback } callback return callback used to return the result.
|
||||
* @syscap SystemCapability.Communication.NetStack
|
||||
* @crossplatform
|
||||
* @since 10
|
||||
*/
|
||||
off(type: 'error', callback?: ErrorCallback): void;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user