• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 
37 public:
38     SoftbusSession();
39     ~SoftbusSession();
40 
41     /**
42      * @tc.name: SoftbusSession::RegisterSessionCallback
43      * @tc.desc: RegisterSessionCallback of the Softbus Session
44      * @tc.type: FUNC
45      */
46     int32_t RegisterSessionCallback(std::shared_ptr<ISoftbusSessionCallback> callback);
47 
48     /**
49      * @tc.name: SoftbusSession::UnRegisterSessionCallback
50      * @tc.desc: UnRegister SessionCallback of the Softbus Session
51      * @tc.type: FUNC
52      */
53     int32_t UnRegisterSessionCallback();
54 
55     /**
56      * @tc.name: SoftbusSession::OpenAuthSession
57      * @tc.desc: Open AuthSession of the Softbus Session
58      * @tc.type: FUNC
59      */
60     int32_t OpenAuthSession(const std::string &deviceId);
61 
62     /**
63      * @tc.name: SoftbusSession::CloseAuthSession
64      * @tc.desc: Close AuthSession of the Softbus Session
65      * @tc.type: FUNC
66      */
67     int32_t CloseAuthSession(int32_t sessionId);
68 
69     /**
70      * @tc.name: SoftbusSession::SendData
71      * @tc.desc: Send Data of the Softbus Session
72      * @tc.type: FUNC
73      */
74     int32_t SendData(int32_t sessionId, std::string &message);
75 
76     /**
77      * @tc.name: SoftbusSession::GetPeerDeviceId
78      * @tc.desc: Get Peer DeviceId of the Softbus Session
79      * @tc.type: FUNC
80      */
81     int32_t GetPeerDeviceId(int32_t sessionId, std::string &peerDevId);
82 
83 private:
84     static std::shared_ptr<ISoftbusSessionCallback> sessionCallback_;
85 };
86 } // namespace DistributedHardware
87 } // namespace OHOS
88 #endif // OHOS_DM_SOFTBUS_SESSION_H
89