• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 OHOS_DEVICE_MANAGER_SOFTBUS_SESSION_H
17 #define OHOS_DEVICE_MANAGER_SOFTBUS_SESSION_H
18 
19 #include <set>
20 #include <vector>
21 #include <string>
22 
23 #include "session.h"
24 #include "single_instance.h"
25 #include "softbus_common.h"
26 
27 namespace OHOS {
28 namespace DistributedHardware {
29 class SoftbusSession {
30 DECLARE_SINGLE_INSTANCE_BASE(SoftbusSession);
31 public:
32     int32_t Start();
33     int32_t OnSessionOpened(int32_t sessionId, int32_t result);
34     void OnSessionClosed(int32_t sessionId);
35     void OnBytesReceived(int32_t sessionId, const void *data, uint32_t dataLen);
36     void CloseSession(int32_t sessionId);
37     int32_t SendMessages(const char *deviceId, std::vector<std::string> &messages);
38     int32_t SendMsg(int32_t sessionId, std::string &message);
39     void GetPeerDeviceId(int32_t sessionId, std::string &peerDevId);
40 private:
41     SoftbusSession() = default;
42     ~SoftbusSession();
43 private:
44     int32_t SendData(int32_t sessionId, const void *data, int32_t len);
45 private:
46     const char *PKG_NAME = "ohos.distributedhardware.devicemanager";
47     const char *SESSION_NAME = "ohos.distributedhardware.devicemanager.resident";
48     std::set<int32_t> sessionIdSet_;
49     std::vector<std::string> messages_ {};
50 };
51 } // namespace DistributedHardware
52 } // namespace OHOS
53 #endif // OHOS_DEVICE_MANAGER_SOFTBUS_SESSION_H
54