1 /* 2 * Copyright (c) 2021 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 SOFTBUS_SESSION_H 17 #define SOFTBUS_SESSION_H 18 19 #include <array> 20 #include <cstdint> 21 #include <string> 22 #include "transport/socket.h" 23 #include "transport/trans_type.h" 24 #include "network/base_session.h" 25 26 namespace OHOS { 27 namespace Storage { 28 namespace DistributedFile { 29 constexpr int32_t INVALID_SOCKET_FD = -1; 30 class SoftbusSession final : public BaseSession { 31 public: 32 explicit SoftbusSession(int32_t sessionId, std::string peerDeviceId); 33 ~SoftbusSession() = default; 34 bool IsFromServer() const override; 35 std::string GetCid() const override; 36 int32_t GetHandle() const override; 37 int GetSessionId() const override; 38 std::array<char, KEY_SIZE_MAX> GetKey() const override; 39 void Release() const override; 40 void DisableSessionListener() const override; 41 void SetFromServer(bool isServer); 42 43 private: 44 int32_t sessionId_; 45 std::string cid_; 46 int32_t socketFd_ {INVALID_SOCKET_FD}; 47 std::array<char, KEY_SIZE_MAX> key_; 48 bool IsServerSide_ = false; 49 }; 50 } // namespace DistributedFile 51 } // namespace Storage 52 } // namespace OHOS 53 #endif // SOFTBUS_SESSION_H