1 /* 2 * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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 OHOS_SHARING_ICLIENT_H 17 #define OHOS_SHARING_ICLIENT_H 18 19 #include <cstdint> 20 #include "iclient_callback.h" 21 #include "network/data/socket_info.h" 22 23 namespace OHOS { 24 namespace Sharing { 25 class IClient { 26 public: 27 using Ptr = std::shared_ptr<IClient>; 28 29 IClient() = default; 30 virtual ~IClient() = default; 31 32 virtual void Disconnect() = 0; 33 virtual bool Connect(const std::string &peerHost, uint16_t peerPort, const std::string &localIp, 34 uint16_t localPort) = 0; 35 36 virtual bool Send(const std::string &msg) = 0; 37 virtual bool Send(const char *buf, int32_t nSize) = 0; 38 virtual bool Send(const DataBuffer::Ptr &buf, int32_t nSize) = 0; 39 40 virtual SocketInfo::Ptr GetSocketInfo() = 0; 41 virtual void SetRecvOption(int32_t flags) = 0; 42 virtual void RegisterCallback(std::weak_ptr<IClientCallback> callback) = 0; 43 }; 44 } // namespace Sharing 45 } // namespace OHOS 46 #endif