1/* 2 * Copyright (c) 2020 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit ArkUI 19 */ 20 21/** 22 * @typedef SubscribeMessageResponse 23 * @syscap SystemCapability.ArkUI.ArkUI.Lite 24 * @since 5 25 * @deprecated since 8 26 */ 27export interface SubscribeMessageResponse { 28 /** 29 * Peer device ID. 30 * @syscap SystemCapability.ArkUI.ArkUI.Lite 31 * @since 5 32 * @deprecated since 8 33 */ 34 deviceId: string; 35 36 /** 37 * Name of the bundle where the peer ability has been located. The name is case sensitive. 38 * @syscap SystemCapability.ArkUI.ArkUI.Lite 39 * @since 5 40 * @deprecated since 8 41 */ 42 bundleName: string; 43 44 /** 45 * Peer ability name, which is case sensitive. 46 * @syscap SystemCapability.ArkUI.ArkUI.Lite 47 * @since 5 48 * @deprecated since 8 49 */ 50 abilityName: string; 51 52 /** 53 * Messages received from the device. 54 * @syscap SystemCapability.ArkUI.ArkUI.Lite 55 * @since 5 56 * @deprecated since 8 57 */ 58 message: string; 59} 60 61/** 62 * @typedef SendMessageOptions 63 * @syscap SystemCapability.ArkUI.ArkUI.Lite 64 * @since 5 65 * @deprecated since 8 66 */ 67export interface SendMessageOptions { 68 /** 69 * Destination device ID. 70 * @syscap SystemCapability.ArkUI.ArkUI.Lite 71 * @since 5 72 * @deprecated since 8 73 */ 74 deviceId: string; 75 76 /** 77 * Name of the destination bundle where the ability has been located. The name is case sensitive. 78 * @syscap SystemCapability.ArkUI.ArkUI.Lite 79 * @since 5 80 * @deprecated since 8 81 */ 82 bundleName: string; 83 84 /** 85 * Destination ability name, which is case sensitive. 86 * @syscap SystemCapability.ArkUI.ArkUI.Lite 87 * @since 5 88 * @deprecated since 8 89 */ 90 abilityName: string; 91 92 /** 93 * Messages sent to the destination device. 94 * A maximum of 1 KB of data can be transmitted at a time. 95 * If more than 1 KB of data needs to be transmitted, split the messages into multiple parts to transmit. 96 * @syscap SystemCapability.ArkUI.ArkUI.Lite 97 * @since 5 98 * @deprecated since 8 99 */ 100 message?: string; 101 102 /** 103 * Called when the messages are sent successfully. 104 * @syscap SystemCapability.ArkUI.ArkUI.Lite 105 * @since 5 106 * @deprecated since 8 107 */ 108 success?: () => void; 109 110 /** 111 * Called when the messages fail to be sent. 112 * @syscap SystemCapability.ArkUI.ArkUI.Lite 113 * @since 5 114 * @deprecated since 8 115 */ 116 fail?: (data: string, code: number) => void; 117 118 /** 119 * Called when the execution is completed. 120 * @syscap SystemCapability.ArkUI.ArkUI.Lite 121 * @since 5 122 * @deprecated since 8 123 */ 124 complete?: () => void; 125} 126 127/** 128 * @typedef SubscribeMessageOptions 129 * @syscap SystemCapability.ArkUI.ArkUI.Lite 130 * @since 5 131 * @deprecated since 8 132 */ 133export interface SubscribeMessageOptions { 134 /** 135 * Called when the messages are sent successfully. 136 * @syscap SystemCapability.ArkUI.ArkUI.Lite 137 * @since 5 138 * @deprecated since 8 139 */ 140 success?: (data: SubscribeMessageResponse) => void; 141 142 /** 143 * Called when the messages fail to be sent. 144 * @syscap SystemCapability.ArkUI.ArkUI.Lite 145 * @since 5 146 * @deprecated since 8 147 */ 148 fail?: (data: string, code: number) => void; 149} 150 151/** 152 * @syscap SystemCapability.ArkUI.ArkUI.Lite 153 * @systemapi 154 * @since 5 155 * @deprecated since 8 156 * @useinstead ohos.ability.featureAbility.FeatureAbility 157 */ 158export declare class FeatureAbility { 159 /** 160 * Sends messages to the destination device. 161 * @param { SendMessageOptions } options - Options. 162 * @syscap SystemCapability.ArkUI.ArkUI.Lite 163 * @systemapi 164 * @since 5 165 * @deprecated since 8 166 */ 167 static sendMsg(options: SendMessageOptions): void; 168 169 /** 170 * Listens for messages sent from other devices. 171 * @param { SubscribeMessageOptions } options - Options. 172 * @syscap SystemCapability.ArkUI.ArkUI.Lite 173 * @systemapi 174 * @since 5 175 * @deprecated since 8 176 */ 177 static subscribeMsg(options: SubscribeMessageOptions): void; 178 179 /** 180 * Cancel the listening for messages sent from other devices. 181 * @syscap SystemCapability.ArkUI.ArkUI.Lite 182 * @systemapi 183 * @since 5 184 * @deprecated since 8 185 */ 186 static unsubscribeMsg(): void; 187} 188