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