1 /* 2 * Copyright (c) 2024 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 IAM_SOFT_CLIENT_SOCKET_H 17 #define IAM_SOFT_CLIENT_SOCKET_H 18 19 #include <optional> 20 21 #include "soft_bus_base_socket.h" 22 23 #define LOG_TAG "USER_AUTH_SA" 24 namespace OHOS { 25 namespace UserIam { 26 namespace UserAuth { 27 class ClientSocket : public BaseSocket { 28 public: 29 ClientSocket(const int32_t socketId); 30 ~ClientSocket() override; 31 32 ResultCode SendMessage(const std::string &connectionName, const std::string &srcEndPoint, 33 const std::string &destEndPoint, const std::shared_ptr<Attributes> &attributes, MsgCallback &callback) override; 34 35 void OnBind(int32_t socketId, PeerSocketInfo info) override; 36 void OnShutdown(int32_t socketId, ShutdownReason reason) override; 37 void OnBytes(int32_t socketId, const void *data, uint32_t dataLen) override; 38 void OnQos(int32_t socketId, QoSEvent eventId, const QosTV *qos, uint32_t qosCount) override; 39 40 std::string GetConnectionName() override; 41 std::string GetNetworkId() override; 42 void SetConnectionName(const std::string &connectionName); 43 void SetNetworkId(const std::string &networkId); 44 45 private: 46 void RefreshKeepAliveTimer(); 47 void SendKeepAliveMessage(); 48 49 std::string connectionName_; 50 std::string endPointName_; 51 std::string networkId_; 52 std::optional<uint32_t> keepAliveTimerId_ = std::nullopt; 53 }; 54 } // namespace UserAuth 55 } // namespace UserIam 56 } // namespace OHOS 57 #endif // IAM_SOFT_CLIENT_SOCKET_H 58