• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 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
16import rpc from '@ohos.rpc'
17import { updateWeatherCallback } from './i_idl_weather_service'
18import IIdlWeatherService from './i_idl_weather_service'
19import Logger from '../../../util/Logger'
20
21export default class IdlWeatherServiceStub extends rpc.RemoteObject implements IIdlWeatherService {
22  constructor(des: string) {
23    super(des)
24  }
25
26  onRemoteRequest(code: number, data, reply, option): boolean {
27    Logger.info("onRemoteRequest called, code = " + code)
28    switch (code) {
29      case IdlWeatherServiceStub.COMMAND_UPDATE_WEATHER: {
30        let _data = data.readInt()
31        this.updateWeather(_data, (errCode, returnValue) => {
32          reply.writeInt(errCode)
33          if (errCode == 0) {
34            reply.writeInt(returnValue)
35          }
36        })
37        return true
38      }
39      default: {
40        Logger.error("invalid request code" + code)
41        break
42      }
43    }
44    return false
45  }
46
47  updateWeather(data: number, callback: updateWeatherCallback): void {
48  }
49
50  static readonly COMMAND_UPDATE_WEATHER = 1
51}
52
53