X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=homescreen%2Fsrc%2FAglShellGrpcClient.cpp;h=ee7510fca8a1b290626209b62a02aac8a939d57f;hb=5d6e250cf1175ede73764514b3cd9359467ddcaf;hp=6f4ff24ae5cb32d6d735af76b3d3c613fa553a38;hpb=36e2c9697e431414ae0263635f3ebf1f3c200723;p=apps%2Fhomescreen.git diff --git a/homescreen/src/AglShellGrpcClient.cpp b/homescreen/src/AglShellGrpcClient.cpp index 6f4ff24..ee7510f 100644 --- a/homescreen/src/AglShellGrpcClient.cpp +++ b/homescreen/src/AglShellGrpcClient.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -14,6 +15,9 @@ #include "AglShellGrpcClient.h" #include "agl_shell.grpc.pb.h" +#include "hmi-debug.h" + +using namespace std::chrono; namespace { const char kDefaultGrpcServiceAddress[] = "127.0.0.1:14005"; @@ -21,9 +25,25 @@ namespace { GrpcClient::GrpcClient() { + struct timespec ts; auto channel = grpc::CreateChannel(kDefaultGrpcServiceAddress, grpc::InsecureChannelCredentials()); + clock_gettime(CLOCK_MONOTONIC, &ts); + ts.tv_sec = 0; + ts.tv_nsec = 500 * 1000 * 1000; // 500ms + + bool try_to_connect = true; + grpc_connectivity_state state = channel->GetState(try_to_connect); + + while (state != GRPC_CHANNEL_READY) { + state = channel->GetState(try_to_connect); + + HMI_DEBUG("HomesScreen", "waiting for channel state to be ready, current state %d", state); + nanosleep(&ts, NULL); + } + + // init the stub here m_stub = agl_shell_ipc::AglShellManagerService::NewStub(channel); reader = new Reader(m_stub.get()); @@ -159,9 +179,9 @@ GrpcClient::Wait(void) } void -GrpcClient::AppStatusState(Callback callback) +GrpcClient::AppStatusState(Callback callback, void *data) { - reader->AppStatusState(callback); + reader->AppStatusState(callback, data); } std::vector