30 lines
813 B
C++
30 lines
813 B
C++
#include <iostream>
|
|
#include <memory>
|
|
#include <grpc/grpc.h>
|
|
#include <grpcpp/channel.h>
|
|
#include <grpcpp/client_context.h>
|
|
#include <grpcpp/create_channel.h>
|
|
#include <grpcpp/security/credentials.h>
|
|
|
|
#include "sensor.pb.h"
|
|
#include "sensor.grpc.pb.h"
|
|
|
|
int main() {
|
|
auto channel = std::shared_ptr(grpc::CreateChannel("localhost:50051", grpc::InsecureChannelCredentials()));
|
|
auto stub = Sensor::NewStub(channel);
|
|
|
|
grpc::ClientContext context;
|
|
|
|
StatusRequest request;
|
|
SensorStatus status;
|
|
grpc::Status rpc_status = stub->get_status(&context, request, &status);
|
|
|
|
if( rpc_status.ok() ) {
|
|
std::cout << "Sensor Status:" << std::endl;
|
|
std::cout << status.DebugString() << std::endl;
|
|
} else {
|
|
std::cout << "get_status() failed" << std::endl;
|
|
}
|
|
|
|
return 0;
|
|
}
|