(void) data;
(void) app_id;
- LOG("got app_on_output event app_id %s on output\n", app_id, output_name);
+ LOG("got app_on_output event app_id %s on output %s\n", app_id, output_name);
}
wl_display = wl_display_connect(NULL);
if (!wl_display) {
- goto err;
+ ret = -1;
+ goto err_failed_display;
}
registry = wl_display_get_registry(wl_display);
sh->wait_for_bound = true;
err:
wl_registry_destroy(registry);
wl_display_disconnect(wl_display);
+
+err_failed_display:
delete sh;
return ret;
}
}
static void
-start_grpc_server(Shell *aglShell)
+start_grpc_server(std::shared_ptr<grpc::Server> server)
{
+ LOG("gRPC server listening\n");
+ server->Wait();
+}
+
+int main(int argc, char **argv)
+{
+ (void) argc;
+ (void) argv;
+ Shell *aglShell = nullptr;
+ int ret = 0;
+
// instantiante the grpc server
std::string server_address(kDefaultGrpcServiceAddress);
GrpcServiceImpl service{aglShell};
builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
builder.RegisterService(&service);
- std::unique_ptr<grpc::Server> server(builder.BuildAndStart());
- LOG("gRPC server listening on %s\n", server_address.c_str());
-
- server->Wait();
-}
-
-int main(int argc, char **argv)
-{
- (void) argc;
- (void) argv;
- Shell *aglShell;
- int ret = 0;
+ std::shared_ptr<grpc::Server> server(builder.BuildAndStart());
+ std::thread thread(start_grpc_server, server);
// this blocks until we detect that another shell client started
// running
std::shared_ptr<struct agl_shell> agl_shell{sh->shell, agl_shell_destroy};
aglShell = new Shell(agl_shell, sh);
- std::thread thread(start_grpc_server, aglShell);
+ // now that we have aglShell, set it to the gRPC proxy as well
+ service.setAglShell(aglShell);
// serve wayland requests
while (running && ret != -1) {