• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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 "softbus_session_callback.h"
28 
29 namespace OHOS {
30 namespace DistributedHardware {
31 class SoftbusSession {
32 public:
33     static int OnSessionOpened(int sessionId, int result);
34     static void OnSessionClosed(int sessionId);
35     static void OnBytesReceived(int sessionId, const void *data, unsigned int dataLen);
36     static void OnUnbindSessionOpened(int sessionId, int result);
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 OpenUnbindSession(const std::string &netWorkId);
84 
85     int32_t SendHeartbeatData(int32_t sessionId, std::string &message);
86 
87 private:
88     static std::shared_ptr<ISoftbusSessionCallback> sessionCallback_;
89 };
90 } // namespace DistributedHardware
91 } // namespace OHOS
92 #endif // OHOS_DM_SOFTBUS_SESSION_H
93