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