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 2023 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_SERVER_CONTROL_SERVER_INTERNAL_H_
21 : #define FIREBOLT_RIALTO_SERVER_CONTROL_SERVER_INTERNAL_H_
22 :
23 : #include <memory>
24 :
25 : #include "IControlServerInternal.h"
26 : #include "IMainThread.h"
27 :
28 : namespace firebolt::rialto::server
29 : {
30 : class ControlServerInternalFactory : public IControlServerInternalFactory
31 : {
32 : public:
33 1 : ControlServerInternalFactory() = default;
34 1 : ~ControlServerInternalFactory() override = default;
35 :
36 : std::shared_ptr<IControl> createControl() const override;
37 : std::shared_ptr<IControlServerInternal>
38 : createControlServerInternal(int id, const std::shared_ptr<IControlClientServerInternal> &client) const override;
39 : };
40 :
41 : class ControlServerInternal : public IControlServerInternal
42 : {
43 : public:
44 : explicit ControlServerInternal(const std::shared_ptr<IMainThreadFactory> &mainThreadFactory, int id,
45 : const std::shared_ptr<IControlClientServerInternal> &client);
46 : ~ControlServerInternal() override;
47 :
48 : void ack(int32_t id) override;
49 : void setApplicationState(const ApplicationState &state) override;
50 : void ping(std::unique_ptr<IHeartbeatHandler> &&heartbeatHandler) override;
51 : bool registerClient(std::weak_ptr<IControlClient> client, ApplicationState &appState) override;
52 :
53 : private:
54 : const int m_controlId;
55 : std::shared_ptr<IControlClientServerInternal> m_client;
56 : ApplicationState m_currentState;
57 : std::shared_ptr<IMainThread> m_mainThread;
58 : std::unique_ptr<IHeartbeatHandler> m_heartbeatHandler;
59 : uint32_t m_mainThreadClientId;
60 : };
61 : } // namespace firebolt::rialto::server
62 :
63 : #endif // FIREBOLT_RIALTO_SERVER_CONTROL_SERVER_INTERNAL_H_
|