• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 * @typedef SubscribeMessageResponse
18 * @syscap SystemCapability.ArkUI.ArkUI.Lite
19 * @since 5
20 * @deprecated since 8
21 */
22export interface SubscribeMessageResponse {
23  /**
24   * Peer device ID.
25   * @syscap SystemCapability.ArkUI.ArkUI.Lite
26   * @since 5
27   * @deprecated since 8
28   */
29  deviceId: string;
30
31  /**
32   * Name of the bundle where the peer ability has been located. The name is case sensitive.
33   * @syscap SystemCapability.ArkUI.ArkUI.Lite
34   * @since 5
35   * @deprecated since 8
36   */
37  bundleName: string;
38
39  /**
40   * Peer ability name, which is case sensitive.
41   * @syscap SystemCapability.ArkUI.ArkUI.Lite
42   * @since 5
43   * @deprecated since 8
44   */
45  abilityName: string;
46
47  /**
48   * Messages received from the device.
49   * @syscap SystemCapability.ArkUI.ArkUI.Lite
50   * @since 5
51   * @deprecated since 8
52   */
53  message: string;
54}
55
56/**
57 * @typedef SendMessageOptions
58 * @syscap SystemCapability.ArkUI.ArkUI.Lite
59 * @since 5
60 * @deprecated since 8
61 */
62export interface SendMessageOptions {
63  /**
64   * Destination device ID.
65   * @syscap SystemCapability.ArkUI.ArkUI.Lite
66   * @since 5
67   * @deprecated since 8
68   */
69  deviceId: string;
70
71  /**
72   * Name of the destination bundle where the ability has been located. The name is case sensitive.
73   * @syscap SystemCapability.ArkUI.ArkUI.Lite
74   * @since 5
75   * @deprecated since 8
76   */
77  bundleName: string;
78
79  /**
80   * Destination ability name, which is case sensitive.
81   * @syscap SystemCapability.ArkUI.ArkUI.Lite
82   * @since 5
83   * @deprecated since 8
84   */
85  abilityName: string;
86
87  /**
88   * Messages sent to the destination device.
89   * A maximum of 1 KB of data can be transmitted at a time.
90   * If more than 1 KB of data needs to be transmitted, split the messages into multiple parts to transmit.
91   * @syscap SystemCapability.ArkUI.ArkUI.Lite
92   * @since 5
93   * @deprecated since 8
94   */
95  message?: string;
96
97  /**
98   * Called when the messages are sent successfully.
99   * @syscap SystemCapability.ArkUI.ArkUI.Lite
100   * @since 5
101   * @deprecated since 8
102   */
103  success?: () => void;
104
105  /**
106   * Called when the messages fail to be sent.
107   * @syscap SystemCapability.ArkUI.ArkUI.Lite
108   * @since 5
109   * @deprecated since 8
110   */
111  fail?: (data: string, code: number) => void;
112
113  /**
114   * Called when the execution is completed.
115   * @syscap SystemCapability.ArkUI.ArkUI.Lite
116   * @since 5
117   * @deprecated since 8
118   */
119  complete?: () => void;
120}
121
122/**
123 * @typedef SubscribeMessageOptions
124 * @syscap SystemCapability.ArkUI.ArkUI.Lite
125 * @since 5
126 * @deprecated since 8
127 */
128export interface SubscribeMessageOptions {
129  /**
130   * Called when the messages are sent successfully.
131   * @syscap SystemCapability.ArkUI.ArkUI.Lite
132   * @since 5
133   * @deprecated since 8
134   */
135  success?: (data: SubscribeMessageResponse) => void;
136
137  /**
138   * Called when the messages fail to be sent.
139   * @syscap SystemCapability.ArkUI.ArkUI.Lite
140   * @since 5
141   * @deprecated since 8
142   */
143  fail?: (data: string, code: number) => void;
144}
145
146/**
147 * @syscap SystemCapability.ArkUI.ArkUI.Lite
148 * @systemapi
149 * @since 5
150 * @deprecated since 8
151 * @useinstead ohos.ability.featureAbility.FeatureAbility
152 */
153export declare class FeatureAbility {
154  /**
155   * Sends messages to the destination device.
156   * @param { SendMessageOptions } options - Options.
157   * @syscap SystemCapability.ArkUI.ArkUI.Lite
158   * @systemapi
159   * @since 5
160   * @deprecated since 8
161   */
162  static sendMsg(options: SendMessageOptions): void;
163
164  /**
165   * Listens for messages sent from other devices.
166   * @param { SubscribeMessageOptions } options - Options.
167   * @syscap SystemCapability.ArkUI.ArkUI.Lite
168   * @systemapi
169   * @since 5
170   * @deprecated since 8
171   */
172  static subscribeMsg(options: SubscribeMessageOptions): void;
173
174  /**
175   * Cancel the listening for messages sent from other devices.
176   * @syscap SystemCapability.ArkUI.ArkUI.Lite
177   * @systemapi
178   * @since 5
179   * @deprecated since 8
180   */
181  static unsubscribeMsg(): void;
182}
183