//
// Created by zx on 23-7-15.
//

#include "nav_server.h"


::grpc::Status NavServer::Start(::grpc::ServerContext *context,
                                const ::NavMessage::NavCmd *request, ::NavMessage::NavResponse *response) {
    std::cout << "server received StartCmd: " << request->key() << std::endl;
    if (navigator_ != nullptr) {
        navigator_->Start(*request, *response);
    }
    return ::grpc::Status::OK;
}

::grpc::Status NavServer::Cancel(::grpc::ServerContext *context,
                                 const ::NavMessage::NavCmd *request, ::NavMessage::NavResponse *response) {
    std::cout << "server received Cancel Cmd: " << request->key() << std::endl;
    if (navigator_ != nullptr) {
        navigator_->Cancel(*request, *response);
    }
    return ::grpc::Status::OK;
}

::grpc::Status NavServer::ManualOperation(::grpc::ServerContext *context,
                                          const ::NavMessage::ManualCmd *request, ::NavMessage::NavResponse *response) {
    std::cout << "server received ManualOperation Cmd: " << request->key() << std::endl;
    if (navigator_ != nullptr) {
        navigator_->ManualOperation(*request, *response);
    }
    return ::grpc::Status::OK;
}

