Line data Source code
1 : /*
2 : * If not stated otherwise in this file or this component's LICENSE file the
3 : * following copyright and licenses apply:
4 : *
5 : * Copyright 2022 Sky UK
6 : *
7 : * Licensed under the Apache License, Version 2.0 (the "License");
8 : * you may not use this file except in compliance with the License.
9 : * You may obtain a copy of the License at
10 : *
11 : * http://www.apache.org/licenses/LICENSE-2.0
12 : *
13 : * Unless required by applicable law or agreed to in writing, software
14 : * distributed under the License is distributed on an "AS IS" BASIS,
15 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 : * See the License for the specific language governing permissions and
17 : * limitations under the License.
18 : */
19 :
20 : #ifndef FIREBOLT_RIALTO_IPC_IPC_CLIENT_IMPL_H_
21 : #define FIREBOLT_RIALTO_IPC_IPC_CLIENT_IMPL_H_
22 :
23 : #include "IIpcServer.h"
24 :
25 : #include <sys/socket.h>
26 :
27 : #include <map>
28 : #include <memory>
29 : #include <string>
30 :
31 : namespace firebolt::rialto::ipc
32 : {
33 : class ServerImpl;
34 :
35 : class ClientImpl final : public IClient
36 : {
37 : public:
38 : ClientImpl(const std::shared_ptr<ServerImpl> &server, uint64_t clientId, const struct ucred &creds);
39 23 : ~ClientImpl() final = default;
40 :
41 : public:
42 : pid_t getClientPid() const override;
43 : uid_t getClientUserId() const override;
44 : gid_t getClientGroupId() const override;
45 :
46 : void disconnect() override;
47 :
48 : void exportService(const std::shared_ptr<google::protobuf::Service> &service) override;
49 :
50 : bool sendEvent(const std::shared_ptr<google::protobuf::Message> &message) override;
51 :
52 : bool isConnected() const override;
53 :
54 : protected:
55 : friend class ServerImpl;
56 29 : inline uint64_t id() const { return m_kClientId; }
57 :
58 : private:
59 : const std::weak_ptr<ServerImpl> m_kServer;
60 : const uint64_t m_kClientId{};
61 : const struct ucred m_kCredentials;
62 :
63 : std::map<std::string, std::shared_ptr<google::protobuf::Service>> m_services;
64 : };
65 :
66 : } // namespace firebolt::rialto::ipc
67 :
68 : #endif // FIREBOLT_RIALTO_IPC_IPC_CLIENT_IMPL_H_
|