Panoptes 1.0.0
Endpoint Detection and Response
Loading...
Searching...
No Matches
service_client.cpp
Go to the documentation of this file.
1#include "container_ipc.hpp"
2
3#include <grpcpp/grpcpp.h>
4#include "panoptes.grpc.pb.h"
5
6using grpc::Channel;
7using grpc::ClientContext;
8using grpc::Status;
9
10std::unique_ptr<PanoptesService::Stub> stub_;
11
16 std::string server_url = "localhost:" + std::to_string(SERVICE_PORT);
17 std::shared_ptr<grpc::Channel> channel = grpc::CreateChannel(server_url, grpc::InsecureChannelCredentials());
18 stub_ = PanoptesService::NewStub(channel);
19}
20
25bool PanoptesServiceClient::Hello(ExtensibilityType extensibilityType, std::string port) {
26 AckMessage reply;
27 ContainerInfo request;
28 ClientContext g_context;
29
30 int grpc_port = std::stoi(port);
31 request.set_container_type((ContainerType)extensibilityType);
32 request.set_grpc_port(grpc_port);
33
34 Status status = stub_->Hello(&g_context, request, &reply);
35
36 if (!status.ok()) {
37 std::cout << status.error_code() << ": " << status.error_message() << std::endl;
38 return !reply.ack_type();
39 }
40
41 return !reply.ack_type();
42}
#define SERVICE_PORT
ExtensibilityType
The type of extensibility.
PanoptesServiceClient()
The PanoptesServiceClient class is a class that implements the PanoptesServiceClient class.
bool Hello(ExtensibilityType extensibilityType, std::string port)
The Hello function sends a Hello message to the Panoptes main service from the container.
std::unique_ptr< PanoptesService::Stub > stub_