From 06a431c3c8e0901936051a7721f937583fd7d729 Mon Sep 17 00:00:00 2001 From: anjiaqi Date: Tue, 22 Jul 2025 17:46:05 +0800 Subject: [PATCH] Overload in communication_netstack on 0702 Issue: https://gitee.com/openharmony/interface_sdk-js/issues/ICNPRN Signed-off-by: anjiaqi Change-Id: I5bef205de85d304d6bf4535bc0a4d4b5f8d46b5f --- .../ets/ani/http/ets/@ohos.net.http.ets | 27 ++++++++++++------- .../web_socket/ets/@ohos.net.webSocket.d.ets | 24 ++++++++++------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/frameworks/ets/ani/http/ets/@ohos.net.http.ets b/frameworks/ets/ani/http/ets/@ohos.net.http.ets index 6ec5aac9b..c31f78d6b 100644 --- a/frameworks/ets/ani/http/ets/@ohos.net.http.ets +++ b/frameworks/ets/ani/http/ets/@ohos.net.http.ets @@ -184,11 +184,16 @@ export default namespace http { request(url: string, options?: HttpRequestOptions): Promise; - requestInStream(url: string, callback: AsyncCallback): void; + requestInStreamWithCallback(url: string, callback: AsyncCallback): void; - requestInStream(url: string, options: HttpRequestOptions, callback: AsyncCallback): void; + requestInStreamWithOptionCallback(url: string, options: HttpRequestOptions, callback: AsyncCallback): void; - requestInStream(url: string, options?: HttpRequestOptions): Promise; + requestInStreamWithOptionsReturnsPromise(url: string, options?: HttpRequestOptions): Promise; + + overload requestInStream { + requestInStreamWithCallback, + requestInStreamWithOptionCallback, + requestInStreamWithOptionsReturnsPromise }; destroy(): void; @@ -242,15 +247,15 @@ export default namespace http { native requestInStreamInner(url: string, callback: AsyncCallback, options?: HttpRequestOptions): void; - requestInStream(url: string, callback: AsyncCallback): void { + requestInStreamWithCallback(url: string, callback: AsyncCallback): void { this.requestInStreamInner(url, callback); } - requestInStream(url: string, options: HttpRequestOptions, callback: AsyncCallback): void { + requestInStreamWithOptionCallback(url: string, options: HttpRequestOptions, callback: AsyncCallback): void { this.requestInStreamInner(url, callback, options); } - requestInStream(url: string, options?: HttpRequestOptions): Promise { + requestInStreamWithOptionsReturnsPromise(url: string, options?: HttpRequestOptions): Promise { return new Promise((resolve, reject) => { this.requestInStreamInner(url, (err: BusinessError | null, data: int | undefined) => { if (err) { @@ -535,9 +540,11 @@ export default namespace http { flush(): Promise; - delete(callback: AsyncCallback): void; + deleteWithCallback(callback: AsyncCallback): void; - delete(): Promise; + deleteReturnsPromise(): Promise; + + overload delete { deleteWithCallback, deleteReturnsPromise }; } export class HttpResponseCacheInner implements HttpResponseCache { @@ -585,7 +592,7 @@ export default namespace http { native deleteSync():void; - delete(callback: AsyncCallback): void { + deleteWithCallback(callback: AsyncCallback): void { let p1 = taskpool.execute((): undefined => { return this.deleteSync(); }) @@ -596,7 +603,7 @@ export default namespace http { }); } - delete(): Promise { + deleteReturnsPromise(): Promise { return new Promise((resolve, reject) => { taskpool.execute((): undefined => { return this.deleteSync(); diff --git a/frameworks/ets/ani/web_socket/ets/@ohos.net.webSocket.d.ets b/frameworks/ets/ani/web_socket/ets/@ohos.net.webSocket.d.ets index 3a7492186..c4c595c18 100644 --- a/frameworks/ets/ani/web_socket/ets/@ohos.net.webSocket.d.ets +++ b/frameworks/ets/ani/web_socket/ets/@ohos.net.webSocket.d.ets @@ -73,15 +73,19 @@ export default namespace webSocket { // } export interface WebSocket { - connect(url: string, callback: AsyncCallback): void; + connectWithCallback(url: string, callback: AsyncCallback): void; - connect(url: string, options: WebSocketRequestOptions, callback: AsyncCallback): void; + connectWithOptionsCallback(url: string, options: WebSocketRequestOptions, callback: AsyncCallback): void; - connect(url: string, options?: WebSocketRequestOptions): Promise; + connectWithOptionsReturnsPromise(url: string, options?: WebSocketRequestOptions): Promise; - send(data: string | ArrayBuffer, callback: AsyncCallback): void; + overload connect { connectWithCallback, connectWithOptionsCallback, connectWithOptionsReturnsPromise }; - send(data: string | ArrayBuffer): Promise; + sendWithCallback(data: string | ArrayBuffer, callback: AsyncCallback): void; + + sendReturnsPromise(data: string | ArrayBuffer): Promise; + + overload send { sendWithCallback, sendReturnsPromise }; close(callback: AsyncCallback): void; @@ -135,7 +139,7 @@ export default namespace webSocket { native connectSync(url: string, options?: WebSocketRequestOptions): boolean; - connect(url: string, callback: AsyncCallback): void { + connectWithCallback(url: string, callback: AsyncCallback): void { let p1 = taskpool.execute((): boolean => { return this.connectSync(url); }) @@ -146,7 +150,7 @@ export default namespace webSocket { }); } - connect(url: string, options: WebSocketRequestOptions, callback: AsyncCallback): void { + connectWithOptionsCallback(url: string, options: WebSocketRequestOptions, callback: AsyncCallback): void { let p1 = taskpool.execute((): boolean => { return this.connectSync(url, options); }) @@ -157,7 +161,7 @@ export default namespace webSocket { }); } - connect(url: string, options?: WebSocketRequestOptions): Promise { + connectWithOptionsReturnsPromise(url: string, options?: WebSocketRequestOptions): Promise { return new Promise((resolve, reject) => { taskpool.execute((): boolean => { return this.connectSync(url, options); @@ -171,7 +175,7 @@ export default namespace webSocket { native sendSync(data: string | ArrayBuffer): boolean; - send(data: string | ArrayBuffer, callback: AsyncCallback): void { + sendWithCallback(data: string | ArrayBuffer, callback: AsyncCallback): void { let p1 = taskpool.execute((): boolean => { return this.sendSync(data); }) @@ -182,7 +186,7 @@ export default namespace webSocket { }); } - send(data: string | ArrayBuffer): Promise { + sendReturnsPromise(data: string | ArrayBuffer): Promise { return new Promise((resolve, reject) => { taskpool.execute((): boolean => { return this.sendSync(data); -- Gitee