3 ==================================================================================
4 Copyright (c) 2021 AT&T Intellectual Property.
5 Copyright (c) 2021 Alexandre Huff.
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 ==================================================================================
23 Abstract: Implements a simple echo server just for testing gRPC calls
27 Author: Alexandre Huff
32 #include <grpc/grpc.h>
33 #include <grpcpp/security/server_credentials.h>
34 #include <grpcpp/server.h>
35 #include <grpcpp/server_builder.h>
37 #include "../../ext/protobuf/api.grpc.pb.h"
41 class ControlServiceImpl : public api::MsgComm::Service {
42 ::grpc::Status SendRICControlReqServiceGrpc(::grpc::ServerContext* context, const ::api::RicControlGrpcReq* request,
43 ::api::RicControlGrpcRsp* response) override {
44 cout << "[RC] Received a new gRPC message\n";
47 TODO check if this is related to RICControlAckEnum
48 if yes, then ACK value should be 2 (RIC_CONTROL_ACK)
49 api.proto assumes that 0 is an ACK
51 response->set_rspcode(0);
52 response->set_description("ACK");
54 return ::grpc::Status::OK;
59 string server_address("0.0.0.0:50051");
60 ControlServiceImpl service;
62 grpc::ServerBuilder builder;
63 builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
64 builder.RegisterService(&service);
66 unique_ptr<grpc::Server> server(builder.BuildAndStart());
68 cout << "[RC] Server listening on " << server_address << std::endl;
72 int main(int argc, char const *argv[]) {