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