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_ISERVER_H 17 #define OHOS_SHARING_ISERVER_H 18 19 #include <cstdint> 20 #include <string> 21 #include "iserver_callback.h" 22 #include "network/data/socket_info.h" 23 24 namespace OHOS { 25 namespace Sharing { 26 class IServer { 27 public: 28 using Ptr = std::shared_ptr<IServer>; 29 30 IServer() = default; 31 virtual ~IServer() = default; 32 33 virtual void Stop() = 0; 34 virtual bool Start(uint16_t port, const std::string &host, bool enableReuse = true, uint32_t backlog = 1000) = 0; 35 36 virtual SocketInfo::Ptr GetSocketInfo() = 0; 37 virtual void CloseClientSocket(int32_t fd) = 0; 38 39 virtual std::weak_ptr<IServerCallback> &GetCallback() = 0; 40 virtual void RegisterCallback(std::weak_ptr<IServerCallback> callback) = 0; 41 }; 42 } // namespace Sharing 43 } // namespace OHOS 44 #endif