|
|
@ -42,7 +42,7 @@ |
|
|
|
#include <grpc++/server.h> |
|
|
|
#include <grpc++/server.h> |
|
|
|
#include <grpc++/server_builder.h> |
|
|
|
#include <grpc++/server_builder.h> |
|
|
|
#include <grpc++/server_context.h> |
|
|
|
#include <grpc++/server_context.h> |
|
|
|
#include <grpc++/server_credentials.h> |
|
|
|
#include <grpc++/security/server_credentials.h> |
|
|
|
#include "helper.h" |
|
|
|
#include "helper.h" |
|
|
|
#include "route_guide.grpc.pb.h" |
|
|
|
#include "route_guide.grpc.pb.h" |
|
|
|
|
|
|
|
|
|
|
@ -53,12 +53,12 @@ using grpc::ServerReader; |
|
|
|
using grpc::ServerReaderWriter; |
|
|
|
using grpc::ServerReaderWriter; |
|
|
|
using grpc::ServerWriter; |
|
|
|
using grpc::ServerWriter; |
|
|
|
using grpc::Status; |
|
|
|
using grpc::Status; |
|
|
|
using examples::Point; |
|
|
|
using routeguide::Point; |
|
|
|
using examples::Feature; |
|
|
|
using routeguide::Feature; |
|
|
|
using examples::Rectangle; |
|
|
|
using routeguide::Rectangle; |
|
|
|
using examples::RouteSummary; |
|
|
|
using routeguide::RouteSummary; |
|
|
|
using examples::RouteNote; |
|
|
|
using routeguide::RouteNote; |
|
|
|
using examples::RouteGuide; |
|
|
|
using routeguide::RouteGuide; |
|
|
|
using std::chrono::system_clock; |
|
|
|
using std::chrono::system_clock; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -99,7 +99,7 @@ std::string GetFeatureName(const Point& point, |
|
|
|
class RouteGuideImpl final : public RouteGuide::Service { |
|
|
|
class RouteGuideImpl final : public RouteGuide::Service { |
|
|
|
public: |
|
|
|
public: |
|
|
|
explicit RouteGuideImpl(const std::string& db) { |
|
|
|
explicit RouteGuideImpl(const std::string& db) { |
|
|
|
examples::ParseDb(db, &feature_list_); |
|
|
|
routeguide::ParseDb(db, &feature_list_); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Status GetFeature(ServerContext* context, const Point* point, |
|
|
|
Status GetFeature(ServerContext* context, const Point* point, |
|
|
@ -110,7 +110,7 @@ class RouteGuideImpl final : public RouteGuide::Service { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Status ListFeatures(ServerContext* context, |
|
|
|
Status ListFeatures(ServerContext* context, |
|
|
|
const examples::Rectangle* rectangle, |
|
|
|
const routeguide::Rectangle* rectangle, |
|
|
|
ServerWriter<Feature>* writer) override { |
|
|
|
ServerWriter<Feature>* writer) override { |
|
|
|
auto lo = rectangle->lo(); |
|
|
|
auto lo = rectangle->lo(); |
|
|
|
auto hi = rectangle->hi(); |
|
|
|
auto hi = rectangle->hi(); |
|
|
@ -195,7 +195,7 @@ void RunServer(const std::string& db_path) { |
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv) { |
|
|
|
int main(int argc, char** argv) { |
|
|
|
// Expect only arg: --db_path=path/to/route_guide_db.json.
|
|
|
|
// Expect only arg: --db_path=path/to/route_guide_db.json.
|
|
|
|
std::string db = examples::GetDbFileContent(argc, argv); |
|
|
|
std::string db = routeguide::GetDbFileContent(argc, argv); |
|
|
|
RunServer(db); |
|
|
|
RunServer(db); |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|