X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=homescreen%2Fsrc%2FAglShellGrpcClient.h;h=19cfb753819b9cbf0599f4dfd5e83b4e09f0fcf4;hb=refs%2Fchanges%2F98%2F29598%2F1;hp=ff190f7688441bee8a6c26787732a8fd90b13b0c;hpb=36e2c9697e431414ae0263635f3ebf1f3c200723;p=apps%2Fhomescreen.git diff --git a/homescreen/src/AglShellGrpcClient.h b/homescreen/src/AglShellGrpcClient.h index ff190f7..19cfb75 100644 --- a/homescreen/src/AglShellGrpcClient.h +++ b/homescreen/src/AglShellGrpcClient.h @@ -15,7 +15,7 @@ #include "agl_shell.grpc.pb.h" -typedef void (*Callback)(agl_shell_ipc::AppStateResponse app_response); +typedef void (*Callback)(agl_shell_ipc::AppStateResponse app_response, void *data); class Reader : public grpc::ClientReadReactor<::agl_shell_ipc::AppStateResponse> { public: @@ -24,12 +24,13 @@ public: { } - void AppStatusState(Callback callback) + void AppStatusState(Callback callback, void *_data) { ::agl_shell_ipc::AppStateRequest request; // set up the callback m_callback = callback; + m_data = _data; m_stub->async()->AppStatusState(&m_context, &request, this); StartRead(&m_app_state); @@ -39,7 +40,7 @@ public: void OnReadDone(bool ok) override { if (ok) { - m_callback(m_app_state); + m_callback(m_app_state, m_data); // blocks in StartRead() if the server doesn't send // antyhing @@ -76,6 +77,7 @@ public: private: grpc::ClientContext m_context; ::agl_shell_ipc::AppStateResponse m_app_state; + void *m_data; agl_shell_ipc::AglShellManagerService::Stub *m_stub; Callback m_callback; @@ -90,6 +92,7 @@ private: class GrpcClient { public: GrpcClient(); + void WaitForConnected(int wait_time_ms, int tries_timeout); bool ActivateApp(const std::string& app_id, const std::string& output_name); bool DeactivateApp(const std::string& app_id); bool SetAppFloat(const std::string& app_id, int32_t x_pos, int32_t y_pos); @@ -100,11 +103,12 @@ public: bool SetAppScale(const std::string& app_id, int32_t width, int32_t height); std::vector GetOutputs(); void GetAppState(); - void AppStatusState(Callback callback); + void AppStatusState(Callback callback, void *data); grpc::Status Wait(); private: Reader *reader; std::unique_ptr m_stub; + std::shared_ptr m_channel; };