From c759f9a03ca1b3d6f33b8e4007c7bdb2ea113727 Mon Sep 17 00:00:00 2001
From: root
Date: Sat, 2 Aug 2025 16:53:28 +0800
Subject: [PATCH] support websocket ani
Issue:https://gitee.com/openharmony/interface_sdk-js/issues/ICQLIV
Signed-off-by: leo9001
---
api/@ohos.net.webSocket.d.ts | 173 ++++++++++++++++++++++-------------
1 file changed, 109 insertions(+), 64 deletions(-)
diff --git a/api/@ohos.net.webSocket.d.ts b/api/@ohos.net.webSocket.d.ts
index e582a5f2ed..e38e1e3bb3 100644
--- a/api/@ohos.net.webSocket.d.ts
+++ b/api/@ohos.net.webSocket.d.ts
@@ -382,7 +382,8 @@ declare namespace webSocket {
* HTTP response headers.
* @typedef { object }
* @syscap SystemCapability.Communication.NetStack
- * @since 12
+ * @since arkts {'1.1':'12','1.2':'20'}
+ * @arkts 1.1&1.2
*/
export type ResponseHeaders = {
[k: string]: string | string[] | undefined;
@@ -786,7 +787,8 @@ declare namespace webSocket {
* @syscap SystemCapability.Communication.NetStack
* @crossplatform
* @atomicservice
- * @since 11
+ * @since arkts {'1.1':'11','1.2':'20'}
+ * @arkts 1.1&1.2
*/
on(type: 'open', callback: AsyncCallback
* @interface WebSocketServer
* @syscap SystemCapability.Communication.NetStack
- * @since 19
+ * @since arkts {'1.1':'19','1.2':'20'}
+ * @arkts 1.1&1.2
*/
export interface WebSocketServer {
/**
@@ -1204,7 +1236,8 @@ declare namespace webSocket {
* @throws { BusinessError } 2302005 - Can't listen on the given Port.
* @throws { BusinessError } 2302999 - Websocket other unknown error.
* @syscap SystemCapability.Communication.NetStack
- * @since 19
+ * @since arkts {'1.1':'19','1.2':'20'}
+ * @arkts 1.1&1.2
*/
start(config: WebSocketServerConfig): Promise;
@@ -1214,7 +1247,8 @@ declare namespace webSocket {
* @returns { WebSocketConnection[] } an array consists connections from all clients.
* @throws { BusinessError } 201 - Permission denied.
* @syscap SystemCapability.Communication.NetStack
- * @since 19
+ * @since arkts {'1.1':'19','1.2':'20'}
+ * @arkts 1.1&1.2
*/
listAllConnections(): WebSocketConnection[];
@@ -1227,7 +1261,8 @@ declare namespace webSocket {
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 2302006 - websocket connection does not exist.
* @syscap SystemCapability.Communication.NetStack
- * @since 19
+ * @since arkts {'1.1':'19','1.2':'20'}
+ * @arkts 1.1&1.2
*/
close(connection: WebSocketConnection, options?: webSocket.WebSocketCloseOptions): Promise;
@@ -1240,18 +1275,20 @@ declare namespace webSocket {
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 2302006 - websocket connection does not exist.
* @syscap SystemCapability.Communication.NetStack
- * @since 19
+ * @since arkts {'1.1':'19','1.2':'20'}
+ * @arkts 1.1&1.2
*/
send(data: string | ArrayBuffer, connection: WebSocketConnection): Promise;
- /**
- * Stop listening.
- * @permission ohos.permission.INTERNET
- * @returns { Promise } The Indicating whether the server stops sucessfully.
- * @throws { BusinessError } 201 - Permission denied.
- * @syscap SystemCapability.Communication.NetStack
- * @since 19
- */
+ /**
+ * Stop listening.
+ * @permission ohos.permission.INTERNET
+ * @returns { Promise } The Indicating whether the server stops sucessfully.
+ * @throws { BusinessError } 201 - Permission denied.
+ * @syscap SystemCapability.Communication.NetStack
+ * @since arkts {'1.1':'19','1.2':'20'}
+ * @arkts 1.1&1.2
+ */
stop(): Promise;
/**
@@ -1259,7 +1296,8 @@ declare namespace webSocket {
* @param { 'error' } type - event indicating that the WebSocket Server has encountered an error.
* @param { ErrorCallback } callback - the callback used to return the result.
* @syscap SystemCapability.Communication.NetStack
- * @since 19
+ * @since arkts {'1.1':'19','1.2':'20'}
+ * @arkts 1.1&1.2
*/
on(type: 'error', callback: ErrorCallback): void;
@@ -1268,26 +1306,29 @@ declare namespace webSocket {
* @param { 'connect' } type - event indicating that a client requested to connect the server.
* @param { Callback } callback - the callback used to return the result.
* @syscap SystemCapability.Communication.NetStack
- * @since 19
+ * @since arkts {'1.1':'19','1.2':'20'}
+ * @arkts 1.1&1.2
*/
on(type: 'connect', callback: Callback): void;
- /**
- * Enables listening for events that the server received a message.
- * @param { 'messageReceive' } type - event indicating that the server received a message.
- * @param { Callback } callback - the callback used to return the result.
- * @syscap SystemCapability.Communication.NetStack
- * @since 19
- */
+ /**
+ * Enables listening for events that the server received a message.
+ * @param { 'messageReceive' } type - event indicating that the server received a message.
+ * @param { Callback } callback - the callback used to return the result.
+ * @syscap SystemCapability.Communication.NetStack
+ * @since arkts {'1.1':'19','1.2':'20'}
+ * @arkts 1.1&1.2
+ */
on(type: 'messageReceive', callback: Callback): void;
- /**
- * Enables listening for events that a connection from a given client has been closed.
- * @param { 'close' } type - event indicating that a connection from a given client has been closed.
- * @param { ClientConnectionCloseCallback } callback - the callback function when a client connection is closed.
- * @syscap SystemCapability.Communication.NetStack
- * @since 19
- */
+ /**
+ * Enables listening for events that a connection from a given client has been closed.
+ * @param { 'close' } type - event indicating that a connection from a given client has been closed.
+ * @param { ClientConnectionCloseCallback } callback - the callback function when a client connection is closed.
+ * @syscap SystemCapability.Communication.NetStack
+ * @since arkts {'1.1':'19','1.2':'20'}
+ * @arkts 1.1&1.2
+ */
on(type: 'close', callback: ClientConnectionCloseCallback): void;
/**
@@ -1295,7 +1336,8 @@ declare namespace webSocket {
* @param { 'error' } type - event indicating that the WebSocket Server has encountered an error.
* @param { ErrorCallback } callback - the callback used to return the result.
* @syscap SystemCapability.Communication.NetStack
- * @since 19
+ * @since arkts {'1.1':'19','1.2':'20'}
+ * @arkts 1.1&1.2
*/
off(type: 'error', callback?: ErrorCallback): void;
@@ -1304,7 +1346,8 @@ declare namespace webSocket {
* @param { 'connect' } type - event indicating that a client requested to connect the server.
* @param { Callback } callback - the callback used to return the result.
* @syscap SystemCapability.Communication.NetStack
- * @since 19
+ * @since arkts {'1.1':'19','1.2':'20'}
+ * @arkts 1.1&1.2
*/
off(type: 'connect', callback?: Callback): void;
@@ -1313,7 +1356,8 @@ declare namespace webSocket {
* @param { 'close' } type - event indicating that a connection from a given client has been closed.
* @param { ClientConnectionCloseCallback } callback - the callback used to return the result.
* @syscap SystemCapability.Communication.NetStack
- * @since 19
+ * @since arkts {'1.1':'19','1.2':'20'}
+ * @arkts 1.1&1.2
*/
off(type: 'close', callback?: ClientConnectionCloseCallback): void;
@@ -1322,7 +1366,8 @@ declare namespace webSocket {
* @param { 'messageReceive' } type - event indicating that the server received a message.
* @param { Callback } callback - the callback used to return the result.
* @syscap SystemCapability.Communication.NetStack
- * @since 19
+ * @since arkts {'1.1':'19','1.2':'20'}
+ * @arkts 1.1&1.2
*/
off(type: 'messageReceive', callback?: Callback): void;
}
--
Gitee