2 * Copyright © 2022 Collabora, Ltd.
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial
14 * portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 #define GRPC_CALLBACK_API_NONEXPERIMENTAL
32 #include <grpc/grpc.h>
33 #include <grpcpp/grpcpp.h>
34 #include <grpcpp/server.h>
35 #include <grpcpp/server_builder.h>
36 #include <grpcpp/server_context.h>
39 #include <condition_variable>
41 #include <grpcpp/ext/proto_server_reflection_plugin.h>
42 #include <grpcpp/health_check_service_interface.h>
45 #include "agl_shell.grpc.pb.h"
48 const char kDefaultGrpcServiceAddress[] = "127.0.0.1:14005";
51 class Lister : public grpc::ServerWriteReactor<::agl_shell_ipc::AppStateResponse> {
53 Lister(Shell *aglShell);
54 void OnDone() override;
55 void OnWriteDone(bool ok) override;
63 class GrpcServiceImpl final : public agl_shell_ipc::AglShellManagerService::CallbackService {
65 GrpcServiceImpl(Shell *aglShell) : m_aglShell(aglShell) {}
67 grpc::ServerUnaryReactor *ActivateApp(grpc::CallbackServerContext *context,
68 const ::agl_shell_ipc::ActivateRequest* request,
69 ::agl_shell_ipc::ActivateResponse* /*response*/) override;
71 grpc::ServerUnaryReactor *DeactivateApp(grpc::CallbackServerContext *context,
72 const ::agl_shell_ipc::DeactivateRequest* request,
73 ::agl_shell_ipc::DeactivateResponse* /*response*/) override;
75 grpc::ServerUnaryReactor *SetAppFloat(grpc::CallbackServerContext *context,
76 const ::agl_shell_ipc::FloatRequest* request,
77 ::agl_shell_ipc::FloatResponse* /*response*/) override;
79 grpc::ServerUnaryReactor *SetAppSplit(grpc::CallbackServerContext *context,
80 const ::agl_shell_ipc::SplitRequest* request,
81 ::agl_shell_ipc::SplitResponse* /*response*/) override;
83 grpc::ServerUnaryReactor *GetOutputs(grpc::CallbackServerContext *context,
84 const ::agl_shell_ipc::OutputRequest* /* request */,
85 ::agl_shell_ipc::ListOutputResponse* response) override;
87 grpc::ServerUnaryReactor *SetAppNormal(grpc::CallbackServerContext *context,
88 const ::agl_shell_ipc::NormalRequest* request,
89 ::agl_shell_ipc::NormalResponse* /*response*/) override;
91 grpc::ServerUnaryReactor *SetAppFullscreen(grpc::CallbackServerContext *context,
92 const ::agl_shell_ipc::FullscreenRequest* request,
93 ::agl_shell_ipc::FullscreenResponse* /*response*/) override;
95 grpc::ServerUnaryReactor *SetAppOnOutput(grpc::CallbackServerContext *context,
96 const ::agl_shell_ipc::AppOnOutputRequest* request,
97 ::agl_shell_ipc::AppOnOutputResponse* /*response*/) override;
99 grpc::ServerWriteReactor< ::agl_shell_ipc::AppStateResponse>* AppStatusState(
100 ::grpc::CallbackServerContext* /*context*/,
101 const ::agl_shell_ipc::AppStateRequest* /*request*/) override;