1 /* 2 * Copyright (c) 2021-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 16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_JS_MESSAGE_DISPATCHER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_JS_MESSAGE_DISPATCHER_H 18 19 #include "base/memory/ace_type.h" 20 #if defined(PREVIEW) 21 #include "adapter/preview/osal/request_data.h" 22 #endif 23 24 namespace OHOS::Ace { 25 26 class JsMessageDispatcher : public virtual AceType { 27 DECLARE_ACE_TYPE(JsMessageDispatcher, AceType); 28 29 public: 30 JsMessageDispatcher() = default; 31 ~JsMessageDispatcher() override = default; 32 33 #if defined(PREVIEW) 34 virtual void CallCurlFunction(const RequestData requestData, int32_t callbackId) const = 0; 35 #endif 36 37 virtual void Dispatch(const std::string& channel, std::vector<uint8_t>&& data, int32_t id, 38 bool replyToComponent = false) const = 0; 39 40 virtual void DispatchSync( 41 const std::string& group, std::vector<uint8_t>&& data, uint8_t** resData, int64_t& position) const = 0; 42 43 virtual void DispatchPluginError(int32_t callbackId, int32_t errorCode, std::string&& errorMessage) const = 0; 44 }; 45 46 } // namespace OHOS::Ace 47 48 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_JS_MESSAGE_DISPATCHER_H 49