1 /*
2  * Copyright (c) 2022-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 OHOS_DM_SOFTBUS_SESSION_H
17 #define OHOS_DM_SOFTBUS_SESSION_H
18 
19 #include <map>
20 #include <memory>
21 #include <set>
22 #include <string>
23 #include <vector>
24 
25 #include "inner_session.h"
26 #include "session.h"
27 #include "socket.h"
28 #include "softbus_session_callback.h"
29 
30 namespace OHOS {
31 namespace DistributedHardware {
32 class SoftbusSession {
33 public:
34     static int OnSessionOpened(int sessionId, int result);
35     static void OnSessionClosed(int sessionId);
36     static void OnBytesReceived(int sessionId, const void *data, unsigned int dataLen);
37 
38 public:
39     SoftbusSession();
40     ~SoftbusSession();
41 
42     /**
43      * @tc.name: SoftbusSession::RegisterSessionCallback
44      * @tc.desc: RegisterSessionCallback of the Softbus Session
45      * @tc.type: FUNC
46      */
47     int32_t RegisterSessionCallback(std::shared_ptr<ISoftbusSessionCallback> callback);
48 
49     /**
50      * @tc.name: SoftbusSession::UnRegisterSessionCallback
51      * @tc.desc: UnRegister SessionCallback of the Softbus Session
52      * @tc.type: FUNC
53      */
54     int32_t UnRegisterSessionCallback();
55 
56     /**
57      * @tc.name: SoftbusSession::OpenAuthSession
58      * @tc.desc: Open AuthSession of the Softbus Session
59      * @tc.type: FUNC
60      */
61     int32_t OpenAuthSession(const std::string &deviceId);
62 
63     /**
64      * @tc.name: SoftbusSession::CloseAuthSession
65      * @tc.desc: Close AuthSession of the Softbus Session
66      * @tc.type: FUNC
67      */
68     int32_t CloseAuthSession(int32_t sessionId);
69 
70     /**
71      * @tc.name: SoftbusSession::SendData
72      * @tc.desc: Send Data of the Softbus Session
73      * @tc.type: FUNC
74      */
75     int32_t SendData(int32_t sessionId, std::string &message);
76 
77     /**
78      * @tc.name: SoftbusSession::GetPeerDeviceId
79      * @tc.desc: Get Peer DeviceId of the Softbus Session
80      * @tc.type: FUNC
81      */
82     int32_t GetPeerDeviceId(int32_t sessionId, std::string &peerDevId);
83     int32_t SendHeartbeatData(int32_t sessionId, std::string &message);
84 
85 private:
86     static std::shared_ptr<ISoftbusSessionCallback> sessionCallback_;
87     ISocketListener iSocketListener_;
88 };
89 } // namespace DistributedHardware
90 } // namespace OHOS
91 #endif // OHOS_DM_SOFTBUS_SESSION_H
92