1060ff233Sopenharmony_ci/* 2060ff233Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 3060ff233Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4060ff233Sopenharmony_ci * you may not use this file except in compliance with the License. 5060ff233Sopenharmony_ci * You may obtain a copy of the License at 6060ff233Sopenharmony_ci * 7060ff233Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8060ff233Sopenharmony_ci * 9060ff233Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10060ff233Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11060ff233Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12060ff233Sopenharmony_ci * See the License for the specific language governing permissions and 13060ff233Sopenharmony_ci * limitations under the License. 14060ff233Sopenharmony_ci */ 15060ff233Sopenharmony_ci 16060ff233Sopenharmony_ci#ifndef CPP_SESSION_H 17060ff233Sopenharmony_ci#define CPP_SESSION_H 18060ff233Sopenharmony_ci 19060ff233Sopenharmony_ci#include <cstdint> 20060ff233Sopenharmony_ci#include <string> 21060ff233Sopenharmony_ci#include <unistd.h> 22060ff233Sopenharmony_ci#include "CommDefs.h" 23060ff233Sopenharmony_ci 24060ff233Sopenharmony_cinamespace Communication { 25060ff233Sopenharmony_cinamespace SoftBus { 26060ff233Sopenharmony_ciclass COMM_EXPORT Session { 27060ff233Sopenharmony_cipublic: 28060ff233Sopenharmony_ci enum { 29060ff233Sopenharmony_ci TYPE_MESSAGE = 0x01, 30060ff233Sopenharmony_ci TYPE_BYTES = 0x02, 31060ff233Sopenharmony_ci TYPE_FILE = 0x04, 32060ff233Sopenharmony_ci TYPE_STREAM = 0x08, 33060ff233Sopenharmony_ci }; 34060ff233Sopenharmony_ci 35060ff233Sopenharmony_ci enum RouteType { 36060ff233Sopenharmony_ci WIFI_STA = 1, 37060ff233Sopenharmony_ci WIFI_P2P = 2, 38060ff233Sopenharmony_ci BT_BR = 3, 39060ff233Sopenharmony_ci BT_BLE = 4, 40060ff233Sopenharmony_ci LOOPBACK = 5, 41060ff233Sopenharmony_ci }; 42060ff233Sopenharmony_ci 43060ff233Sopenharmony_ci enum SessionStatus { 44060ff233Sopenharmony_ci INIT, 45060ff233Sopenharmony_ci OPENING, 46060ff233Sopenharmony_ci OPENED, 47060ff233Sopenharmony_ci CONNECTING, 48060ff233Sopenharmony_ci CONNECTED, 49060ff233Sopenharmony_ci CLOSING, 50060ff233Sopenharmony_ci CLOSED, 51060ff233Sopenharmony_ci }; 52060ff233Sopenharmony_ci 53060ff233Sopenharmony_ci Session() = default; 54060ff233Sopenharmony_ci virtual ~Session() = default; 55060ff233Sopenharmony_ci 56060ff233Sopenharmony_ci virtual const std::string &GetMySessionName() const = 0; 57060ff233Sopenharmony_ci 58060ff233Sopenharmony_ci virtual const std::string &GetPeerSessionName() const = 0; 59060ff233Sopenharmony_ci 60060ff233Sopenharmony_ci virtual const std::string &GetDeviceId() const = 0; 61060ff233Sopenharmony_ci 62060ff233Sopenharmony_ci virtual const std::string &GetPeerDeviceId() const = 0; 63060ff233Sopenharmony_ci 64060ff233Sopenharmony_ci virtual int64_t GetChannelId() const = 0; 65060ff233Sopenharmony_ci 66060ff233Sopenharmony_ci virtual uid_t GetPeerUid() const = 0; 67060ff233Sopenharmony_ci 68060ff233Sopenharmony_ci virtual pid_t GetPeerPid() const = 0; 69060ff233Sopenharmony_ci 70060ff233Sopenharmony_ci virtual bool IsServerSide() const = 0; 71060ff233Sopenharmony_ci 72060ff233Sopenharmony_ci virtual int SendBytes(const void *buf, ssize_t len) const = 0; 73060ff233Sopenharmony_ci 74060ff233Sopenharmony_ci virtual int GetSessionId() const = 0; 75060ff233Sopenharmony_ci 76060ff233Sopenharmony_ci virtual void SetSessionId(int sessionId) = 0; 77060ff233Sopenharmony_ci 78060ff233Sopenharmony_ci virtual void SetMySessionName(const std::string &name) = 0; 79060ff233Sopenharmony_ci 80060ff233Sopenharmony_ci virtual void SetPeerSessionName(const std::string &name) = 0; 81060ff233Sopenharmony_ci 82060ff233Sopenharmony_ci virtual void SetPeerDeviceId(const std::string &name) = 0; 83060ff233Sopenharmony_ci 84060ff233Sopenharmony_ci virtual void SetDeviceId(const std::string &name) = 0; 85060ff233Sopenharmony_ci 86060ff233Sopenharmony_ci virtual void SetIsServer(bool isServer) = 0; 87060ff233Sopenharmony_ci 88060ff233Sopenharmony_ci virtual void SetPeerUid(uid_t peerUid) = 0; 89060ff233Sopenharmony_ci 90060ff233Sopenharmony_ci virtual void SetPeerPid(pid_t peerPid) = 0; 91060ff233Sopenharmony_ci 92060ff233Sopenharmony_ciprivate: 93060ff233Sopenharmony_ci NO_COPY_AND_ASSIGN(Session); 94060ff233Sopenharmony_ci}; 95060ff233Sopenharmony_ci} // namespace SoftBus 96060ff233Sopenharmony_ci} // namespace Communication 97060ff233Sopenharmony_ci 98060ff233Sopenharmony_ci#endif // CPP_SESSION_H 99