• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# MissionCallback
2
3The **MissionCallback** module defines the callbacks invoked after synchronization starts. These callbacks can be used as input parameters in [registerMissionListener](js-apis-distributedMissionManager.md#distributedmissionmanagerregistermissionlistener).
4
5**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
6
7| Name                                                | Template    | Readable| Writable| Description                              |
8| ---------------------------------------------------- | -------- | ---- | ---- | ---------------------------------- |
9| notifyMissionsChanged(deviceId: string)              | function | Yes  | No  | Callback used to notify the mission change event and return the device ID.        |
10| notifySnapshot(deviceId: string, mission: number)    | function | Yes  | No  | Callback used to notify the snapshot change event and return the device ID and mission ID.  |
11| notifyNetDisconnect(deviceId: string, state: number) | function | Yes  | No  | Callback used to notify the disconnection event and return the device ID and network status.|
12
13**Example**
14```ts
15import distributedMissionManager from '@ohos.distributedMissionManager';
16
17let missionDeviceInfo = {
18    deviceId: '123456'
19};
20let missionCallback = {
21    notifyMissionsChanged: function (deviceId) {
22        console.log('notifyMissionsChanged deviceId: ' + JSON.stringify(deviceId));
23    },
24    notifySnapshot: function (deviceId, mission) {
25        console.log('notifySnapshot deviceId: ' + JSON.stringify(deviceId));
26        console.log('notifySnapshot mission: ' + JSON.stringify(mission));
27    },
28    notifyNetDisconnect: function (deviceId, state) {
29        console.log('notifyNetDisconnect deviceId: ' + JSON.stringify(deviceId));
30        console.log('notifyNetDisconnect state: ' + JSON.stringify(state));
31    }
32};
33distributedMissionManager.registerMissionListener(missionDeviceInfo, missionCallback);
34```
35