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 IF_MMI_CLIENT_H 17 #define IF_MMI_CLIENT_H 18 19 #include <functional> 20 21 #include "event_handler.h" 22 23 namespace OHOS { 24 namespace MMI { 25 class NetPacket; 26 class IfMMIClient; 27 using MMIClientPtr = std::shared_ptr<IfMMIClient>; 28 using EventHandlerPtr = std::shared_ptr<AppExecFwk::EventHandler>; 29 typedef std::function<void(const IfMMIClient&)> ConnectCallback; 30 class IfMMIClient { 31 public: 32 virtual MMIClientPtr GetSharedPtr() = 0; 33 virtual bool GetCurrentConnectedStatus() const = 0; 34 virtual bool Start() = 0; 35 virtual bool SendMessage(const NetPacket& pkt) const = 0; 36 virtual void RegisterConnectedFunction(ConnectCallback fun) = 0; 37 virtual void RegisterDisconnectedFunction(ConnectCallback fun) = 0; 38 virtual void OnRecvMsg(const char *buf, size_t size) = 0; 39 virtual int32_t Reconnect() = 0; 40 virtual void OnDisconnect() = 0; 41 virtual void SetEventHandler(EventHandlerPtr eventHandler) = 0; 42 virtual void MarkIsEventHandlerChanged(EventHandlerPtr eventHandler) = 0; 43 virtual bool IsEventHandlerChanged() = 0; 44 virtual EventHandlerPtr GetEventHandler() const = 0; 45 }; 46 } // namespace MMI 47 } // namespace OHOS 48 #endif // IF_MMI_CLIENT_H