mirror of https://github.com/grpc/grpc.git
parent
4eb1a89218
commit
7c7e9c3396
5 changed files with 2887 additions and 0 deletions
@ -0,0 +1,47 @@ |
||||
#
|
||||
# Copyright 2015, Google Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following disclaimer
|
||||
# in the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# * Neither the name of Google Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
CXX=g++
|
||||
CPPFLAGS=-I/usr/local/include -pthread
|
||||
CXXFLAGS=-std=c++11
|
||||
LDFLAGS=-L/usr/local/lib -lgrpc -lgrpc++ -lprotobuf -lpthread -ldl
|
||||
|
||||
all: greeter_client greeter_server |
||||
|
||||
greeter_client: helloworld.pb.o greeter_client.o |
||||
$(CXX) $(CPPFLAGS) $^ $(LDFLAGS) -o $@
|
||||
|
||||
greeter_server: helloworld.pb.o greeter_server.o |
||||
$(CXX) $(CPPFLAGS) $^ $(LDFLAGS) -o $@
|
||||
|
||||
clean: |
||||
rm -f *.o greeter_client greeter_server
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,929 @@ |
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: route_guide.proto
|
||||
|
||||
#ifndef PROTOBUF_route_5fguide_2eproto__INCLUDED |
||||
#define PROTOBUF_route_5fguide_2eproto__INCLUDED |
||||
|
||||
#include <string> |
||||
|
||||
#include <google/protobuf/stubs/common.h> |
||||
|
||||
#if GOOGLE_PROTOBUF_VERSION < 3000000 |
||||
#error This file was generated by a newer version of protoc which is |
||||
#error incompatible with your Protocol Buffer headers. Please update |
||||
#error your headers. |
||||
#endif |
||||
#if 3000000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION |
||||
#error This file was generated by an older version of protoc which is |
||||
#error incompatible with your Protocol Buffer headers. Please |
||||
#error regenerate this file with a newer version of protoc. |
||||
#endif |
||||
|
||||
#include <google/protobuf/arena.h> |
||||
#include <google/protobuf/arenastring.h> |
||||
#include <google/protobuf/generated_message_util.h> |
||||
#include <google/protobuf/metadata.h> |
||||
#include <google/protobuf/message.h> |
||||
#include <google/protobuf/repeated_field.h> |
||||
#include <google/protobuf/extension_set.h> |
||||
#include <google/protobuf/unknown_field_set.h> |
||||
#include <grpc++/impl/internal_stub.h> |
||||
#include <grpc++/impl/service_type.h> |
||||
#include <grpc++/status.h> |
||||
|
||||
namespace grpc { |
||||
class CompletionQueue; |
||||
class ChannelInterface; |
||||
class RpcService; |
||||
class ServerContext; |
||||
template <class OutMessage> class ClientAsyncResponseReader; |
||||
template <class OutMessage> class ServerAsyncResponseWriter; |
||||
template <class OutMessage> class ClientWriter; |
||||
template <class InMessage> class ServerReader; |
||||
template <class OutMessage> class ClientAsyncWriter; |
||||
template <class OutMessage, class InMessage> class ServerAsyncReader; |
||||
template <class InMessage> class ClientReader; |
||||
template <class OutMessage> class ServerWriter; |
||||
template <class OutMessage> class ClientAsyncReader; |
||||
template <class InMessage> class ServerAsyncWriter; |
||||
template <class OutMessage, class InMessage> |
||||
class ClientReaderWriter; |
||||
template <class OutMessage, class InMessage> |
||||
class ServerReaderWriter; |
||||
template <class OutMessage, class InMessage> |
||||
class ClientAsyncReaderWriter; |
||||
template <class OutMessage, class InMessage> |
||||
class ServerAsyncReaderWriter; |
||||
} // namespace grpc
|
||||
// @@protoc_insertion_point(includes)
|
||||
|
||||
namespace examples { |
||||
|
||||
// Internal implementation detail -- do not call these.
|
||||
void protobuf_AddDesc_route_5fguide_2eproto(); |
||||
void protobuf_AssignDesc_route_5fguide_2eproto(); |
||||
void protobuf_ShutdownFile_route_5fguide_2eproto(); |
||||
|
||||
class Point; |
||||
class Rectangle; |
||||
class Feature; |
||||
class RouteNote; |
||||
class RouteSummary; |
||||
|
||||
// ===================================================================
|
||||
|
||||
class Point : public ::google::protobuf::Message { |
||||
public: |
||||
Point(); |
||||
virtual ~Point(); |
||||
|
||||
Point(const Point& from); |
||||
|
||||
inline Point& operator=(const Point& from) { |
||||
CopyFrom(from); |
||||
return *this; |
||||
} |
||||
|
||||
static const ::google::protobuf::Descriptor* descriptor(); |
||||
static const Point& default_instance(); |
||||
|
||||
void Swap(Point* other); |
||||
|
||||
// implements Message ----------------------------------------------
|
||||
|
||||
inline Point* New() const { return New(NULL); } |
||||
|
||||
Point* New(::google::protobuf::Arena* arena) const; |
||||
void CopyFrom(const ::google::protobuf::Message& from); |
||||
void MergeFrom(const ::google::protobuf::Message& from); |
||||
void CopyFrom(const Point& from); |
||||
void MergeFrom(const Point& from); |
||||
void Clear(); |
||||
bool IsInitialized() const; |
||||
|
||||
int ByteSize() const; |
||||
bool MergePartialFromCodedStream( |
||||
::google::protobuf::io::CodedInputStream* input); |
||||
void SerializeWithCachedSizes( |
||||
::google::protobuf::io::CodedOutputStream* output) const; |
||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; |
||||
int GetCachedSize() const { return _cached_size_; } |
||||
private: |
||||
void SharedCtor(); |
||||
void SharedDtor(); |
||||
void SetCachedSize(int size) const; |
||||
void InternalSwap(Point* other); |
||||
private: |
||||
inline ::google::protobuf::Arena* GetArenaNoVirtual() const { |
||||
return _internal_metadata_.arena(); |
||||
} |
||||
inline void* MaybeArenaPtr() const { |
||||
return _internal_metadata_.raw_arena_ptr(); |
||||
} |
||||
public: |
||||
|
||||
::google::protobuf::Metadata GetMetadata() const; |
||||
|
||||
// nested types ----------------------------------------------------
|
||||
|
||||
// accessors -------------------------------------------------------
|
||||
|
||||
// optional int32 latitude = 1;
|
||||
inline void clear_latitude(); |
||||
static const int kLatitudeFieldNumber = 1; |
||||
inline ::google::protobuf::int32 latitude() const; |
||||
inline void set_latitude(::google::protobuf::int32 value); |
||||
|
||||
// optional int32 longitude = 2;
|
||||
inline void clear_longitude(); |
||||
static const int kLongitudeFieldNumber = 2; |
||||
inline ::google::protobuf::int32 longitude() const; |
||||
inline void set_longitude(::google::protobuf::int32 value); |
||||
|
||||
// @@protoc_insertion_point(class_scope:examples.Point)
|
||||
private: |
||||
|
||||
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; |
||||
bool _is_default_instance_; |
||||
::google::protobuf::int32 latitude_; |
||||
::google::protobuf::int32 longitude_; |
||||
mutable int _cached_size_; |
||||
friend void protobuf_AddDesc_route_5fguide_2eproto(); |
||||
friend void protobuf_AssignDesc_route_5fguide_2eproto(); |
||||
friend void protobuf_ShutdownFile_route_5fguide_2eproto(); |
||||
|
||||
void InitAsDefaultInstance(); |
||||
static Point* default_instance_; |
||||
}; |
||||
// -------------------------------------------------------------------
|
||||
|
||||
class Rectangle : public ::google::protobuf::Message { |
||||
public: |
||||
Rectangle(); |
||||
virtual ~Rectangle(); |
||||
|
||||
Rectangle(const Rectangle& from); |
||||
|
||||
inline Rectangle& operator=(const Rectangle& from) { |
||||
CopyFrom(from); |
||||
return *this; |
||||
} |
||||
|
||||
static const ::google::protobuf::Descriptor* descriptor(); |
||||
static const Rectangle& default_instance(); |
||||
|
||||
void Swap(Rectangle* other); |
||||
|
||||
// implements Message ----------------------------------------------
|
||||
|
||||
inline Rectangle* New() const { return New(NULL); } |
||||
|
||||
Rectangle* New(::google::protobuf::Arena* arena) const; |
||||
void CopyFrom(const ::google::protobuf::Message& from); |
||||
void MergeFrom(const ::google::protobuf::Message& from); |
||||
void CopyFrom(const Rectangle& from); |
||||
void MergeFrom(const Rectangle& from); |
||||
void Clear(); |
||||
bool IsInitialized() const; |
||||
|
||||
int ByteSize() const; |
||||
bool MergePartialFromCodedStream( |
||||
::google::protobuf::io::CodedInputStream* input); |
||||
void SerializeWithCachedSizes( |
||||
::google::protobuf::io::CodedOutputStream* output) const; |
||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; |
||||
int GetCachedSize() const { return _cached_size_; } |
||||
private: |
||||
void SharedCtor(); |
||||
void SharedDtor(); |
||||
void SetCachedSize(int size) const; |
||||
void InternalSwap(Rectangle* other); |
||||
private: |
||||
inline ::google::protobuf::Arena* GetArenaNoVirtual() const { |
||||
return _internal_metadata_.arena(); |
||||
} |
||||
inline void* MaybeArenaPtr() const { |
||||
return _internal_metadata_.raw_arena_ptr(); |
||||
} |
||||
public: |
||||
|
||||
::google::protobuf::Metadata GetMetadata() const; |
||||
|
||||
// nested types ----------------------------------------------------
|
||||
|
||||
// accessors -------------------------------------------------------
|
||||
|
||||
// optional .examples.Point lo = 1;
|
||||
inline bool has_lo() const; |
||||
inline void clear_lo(); |
||||
static const int kLoFieldNumber = 1; |
||||
inline const ::examples::Point& lo() const; |
||||
inline ::examples::Point* mutable_lo(); |
||||
inline ::examples::Point* release_lo(); |
||||
inline void set_allocated_lo(::examples::Point* lo); |
||||
|
||||
// optional .examples.Point hi = 2;
|
||||
inline bool has_hi() const; |
||||
inline void clear_hi(); |
||||
static const int kHiFieldNumber = 2; |
||||
inline const ::examples::Point& hi() const; |
||||
inline ::examples::Point* mutable_hi(); |
||||
inline ::examples::Point* release_hi(); |
||||
inline void set_allocated_hi(::examples::Point* hi); |
||||
|
||||
// @@protoc_insertion_point(class_scope:examples.Rectangle)
|
||||
private: |
||||
|
||||
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; |
||||
bool _is_default_instance_; |
||||
::examples::Point* lo_; |
||||
::examples::Point* hi_; |
||||
mutable int _cached_size_; |
||||
friend void protobuf_AddDesc_route_5fguide_2eproto(); |
||||
friend void protobuf_AssignDesc_route_5fguide_2eproto(); |
||||
friend void protobuf_ShutdownFile_route_5fguide_2eproto(); |
||||
|
||||
void InitAsDefaultInstance(); |
||||
static Rectangle* default_instance_; |
||||
}; |
||||
// -------------------------------------------------------------------
|
||||
|
||||
class Feature : public ::google::protobuf::Message { |
||||
public: |
||||
Feature(); |
||||
virtual ~Feature(); |
||||
|
||||
Feature(const Feature& from); |
||||
|
||||
inline Feature& operator=(const Feature& from) { |
||||
CopyFrom(from); |
||||
return *this; |
||||
} |
||||
|
||||
static const ::google::protobuf::Descriptor* descriptor(); |
||||
static const Feature& default_instance(); |
||||
|
||||
void Swap(Feature* other); |
||||
|
||||
// implements Message ----------------------------------------------
|
||||
|
||||
inline Feature* New() const { return New(NULL); } |
||||
|
||||
Feature* New(::google::protobuf::Arena* arena) const; |
||||
void CopyFrom(const ::google::protobuf::Message& from); |
||||
void MergeFrom(const ::google::protobuf::Message& from); |
||||
void CopyFrom(const Feature& from); |
||||
void MergeFrom(const Feature& from); |
||||
void Clear(); |
||||
bool IsInitialized() const; |
||||
|
||||
int ByteSize() const; |
||||
bool MergePartialFromCodedStream( |
||||
::google::protobuf::io::CodedInputStream* input); |
||||
void SerializeWithCachedSizes( |
||||
::google::protobuf::io::CodedOutputStream* output) const; |
||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; |
||||
int GetCachedSize() const { return _cached_size_; } |
||||
private: |
||||
void SharedCtor(); |
||||
void SharedDtor(); |
||||
void SetCachedSize(int size) const; |
||||
void InternalSwap(Feature* other); |
||||
private: |
||||
inline ::google::protobuf::Arena* GetArenaNoVirtual() const { |
||||
return _internal_metadata_.arena(); |
||||
} |
||||
inline void* MaybeArenaPtr() const { |
||||
return _internal_metadata_.raw_arena_ptr(); |
||||
} |
||||
public: |
||||
|
||||
::google::protobuf::Metadata GetMetadata() const; |
||||
|
||||
// nested types ----------------------------------------------------
|
||||
|
||||
// accessors -------------------------------------------------------
|
||||
|
||||
// optional string name = 1;
|
||||
inline void clear_name(); |
||||
static const int kNameFieldNumber = 1; |
||||
inline const ::std::string& name() const; |
||||
inline void set_name(const ::std::string& value); |
||||
inline void set_name(const char* value); |
||||
inline void set_name(const char* value, size_t size); |
||||
inline ::std::string* mutable_name(); |
||||
inline ::std::string* release_name(); |
||||
inline void set_allocated_name(::std::string* name); |
||||
|
||||
// optional .examples.Point location = 2;
|
||||
inline bool has_location() const; |
||||
inline void clear_location(); |
||||
static const int kLocationFieldNumber = 2; |
||||
inline const ::examples::Point& location() const; |
||||
inline ::examples::Point* mutable_location(); |
||||
inline ::examples::Point* release_location(); |
||||
inline void set_allocated_location(::examples::Point* location); |
||||
|
||||
// @@protoc_insertion_point(class_scope:examples.Feature)
|
||||
private: |
||||
|
||||
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; |
||||
bool _is_default_instance_; |
||||
::google::protobuf::internal::ArenaStringPtr name_; |
||||
::examples::Point* location_; |
||||
mutable int _cached_size_; |
||||
friend void protobuf_AddDesc_route_5fguide_2eproto(); |
||||
friend void protobuf_AssignDesc_route_5fguide_2eproto(); |
||||
friend void protobuf_ShutdownFile_route_5fguide_2eproto(); |
||||
|
||||
void InitAsDefaultInstance(); |
||||
static Feature* default_instance_; |
||||
}; |
||||
// -------------------------------------------------------------------
|
||||
|
||||
class RouteNote : public ::google::protobuf::Message { |
||||
public: |
||||
RouteNote(); |
||||
virtual ~RouteNote(); |
||||
|
||||
RouteNote(const RouteNote& from); |
||||
|
||||
inline RouteNote& operator=(const RouteNote& from) { |
||||
CopyFrom(from); |
||||
return *this; |
||||
} |
||||
|
||||
static const ::google::protobuf::Descriptor* descriptor(); |
||||
static const RouteNote& default_instance(); |
||||
|
||||
void Swap(RouteNote* other); |
||||
|
||||
// implements Message ----------------------------------------------
|
||||
|
||||
inline RouteNote* New() const { return New(NULL); } |
||||
|
||||
RouteNote* New(::google::protobuf::Arena* arena) const; |
||||
void CopyFrom(const ::google::protobuf::Message& from); |
||||
void MergeFrom(const ::google::protobuf::Message& from); |
||||
void CopyFrom(const RouteNote& from); |
||||
void MergeFrom(const RouteNote& from); |
||||
void Clear(); |
||||
bool IsInitialized() const; |
||||
|
||||
int ByteSize() const; |
||||
bool MergePartialFromCodedStream( |
||||
::google::protobuf::io::CodedInputStream* input); |
||||
void SerializeWithCachedSizes( |
||||
::google::protobuf::io::CodedOutputStream* output) const; |
||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; |
||||
int GetCachedSize() const { return _cached_size_; } |
||||
private: |
||||
void SharedCtor(); |
||||
void SharedDtor(); |
||||
void SetCachedSize(int size) const; |
||||
void InternalSwap(RouteNote* other); |
||||
private: |
||||
inline ::google::protobuf::Arena* GetArenaNoVirtual() const { |
||||
return _internal_metadata_.arena(); |
||||
} |
||||
inline void* MaybeArenaPtr() const { |
||||
return _internal_metadata_.raw_arena_ptr(); |
||||
} |
||||
public: |
||||
|
||||
::google::protobuf::Metadata GetMetadata() const; |
||||
|
||||
// nested types ----------------------------------------------------
|
||||
|
||||
// accessors -------------------------------------------------------
|
||||
|
||||
// optional .examples.Point location = 1;
|
||||
inline bool has_location() const; |
||||
inline void clear_location(); |
||||
static const int kLocationFieldNumber = 1; |
||||
inline const ::examples::Point& location() const; |
||||
inline ::examples::Point* mutable_location(); |
||||
inline ::examples::Point* release_location(); |
||||
inline void set_allocated_location(::examples::Point* location); |
||||
|
||||
// optional string message = 2;
|
||||
inline void clear_message(); |
||||
static const int kMessageFieldNumber = 2; |
||||
inline const ::std::string& message() const; |
||||
inline void set_message(const ::std::string& value); |
||||
inline void set_message(const char* value); |
||||
inline void set_message(const char* value, size_t size); |
||||
inline ::std::string* mutable_message(); |
||||
inline ::std::string* release_message(); |
||||
inline void set_allocated_message(::std::string* message); |
||||
|
||||
// @@protoc_insertion_point(class_scope:examples.RouteNote)
|
||||
private: |
||||
|
||||
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; |
||||
bool _is_default_instance_; |
||||
::examples::Point* location_; |
||||
::google::protobuf::internal::ArenaStringPtr message_; |
||||
mutable int _cached_size_; |
||||
friend void protobuf_AddDesc_route_5fguide_2eproto(); |
||||
friend void protobuf_AssignDesc_route_5fguide_2eproto(); |
||||
friend void protobuf_ShutdownFile_route_5fguide_2eproto(); |
||||
|
||||
void InitAsDefaultInstance(); |
||||
static RouteNote* default_instance_; |
||||
}; |
||||
// -------------------------------------------------------------------
|
||||
|
||||
class RouteSummary : public ::google::protobuf::Message { |
||||
public: |
||||
RouteSummary(); |
||||
virtual ~RouteSummary(); |
||||
|
||||
RouteSummary(const RouteSummary& from); |
||||
|
||||
inline RouteSummary& operator=(const RouteSummary& from) { |
||||
CopyFrom(from); |
||||
return *this; |
||||
} |
||||
|
||||
static const ::google::protobuf::Descriptor* descriptor(); |
||||
static const RouteSummary& default_instance(); |
||||
|
||||
void Swap(RouteSummary* other); |
||||
|
||||
// implements Message ----------------------------------------------
|
||||
|
||||
inline RouteSummary* New() const { return New(NULL); } |
||||
|
||||
RouteSummary* New(::google::protobuf::Arena* arena) const; |
||||
void CopyFrom(const ::google::protobuf::Message& from); |
||||
void MergeFrom(const ::google::protobuf::Message& from); |
||||
void CopyFrom(const RouteSummary& from); |
||||
void MergeFrom(const RouteSummary& from); |
||||
void Clear(); |
||||
bool IsInitialized() const; |
||||
|
||||
int ByteSize() const; |
||||
bool MergePartialFromCodedStream( |
||||
::google::protobuf::io::CodedInputStream* input); |
||||
void SerializeWithCachedSizes( |
||||
::google::protobuf::io::CodedOutputStream* output) const; |
||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; |
||||
int GetCachedSize() const { return _cached_size_; } |
||||
private: |
||||
void SharedCtor(); |
||||
void SharedDtor(); |
||||
void SetCachedSize(int size) const; |
||||
void InternalSwap(RouteSummary* other); |
||||
private: |
||||
inline ::google::protobuf::Arena* GetArenaNoVirtual() const { |
||||
return _internal_metadata_.arena(); |
||||
} |
||||
inline void* MaybeArenaPtr() const { |
||||
return _internal_metadata_.raw_arena_ptr(); |
||||
} |
||||
public: |
||||
|
||||
::google::protobuf::Metadata GetMetadata() const; |
||||
|
||||
// nested types ----------------------------------------------------
|
||||
|
||||
// accessors -------------------------------------------------------
|
||||
|
||||
// optional int32 point_count = 1;
|
||||
inline void clear_point_count(); |
||||
static const int kPointCountFieldNumber = 1; |
||||
inline ::google::protobuf::int32 point_count() const; |
||||
inline void set_point_count(::google::protobuf::int32 value); |
||||
|
||||
// optional int32 feature_count = 2;
|
||||
inline void clear_feature_count(); |
||||
static const int kFeatureCountFieldNumber = 2; |
||||
inline ::google::protobuf::int32 feature_count() const; |
||||
inline void set_feature_count(::google::protobuf::int32 value); |
||||
|
||||
// optional int32 distance = 3;
|
||||
inline void clear_distance(); |
||||
static const int kDistanceFieldNumber = 3; |
||||
inline ::google::protobuf::int32 distance() const; |
||||
inline void set_distance(::google::protobuf::int32 value); |
||||
|
||||
// optional int32 elapsed_time = 4;
|
||||
inline void clear_elapsed_time(); |
||||
static const int kElapsedTimeFieldNumber = 4; |
||||
inline ::google::protobuf::int32 elapsed_time() const; |
||||
inline void set_elapsed_time(::google::protobuf::int32 value); |
||||
|
||||
// @@protoc_insertion_point(class_scope:examples.RouteSummary)
|
||||
private: |
||||
|
||||
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; |
||||
bool _is_default_instance_; |
||||
::google::protobuf::int32 point_count_; |
||||
::google::protobuf::int32 feature_count_; |
||||
::google::protobuf::int32 distance_; |
||||
::google::protobuf::int32 elapsed_time_; |
||||
mutable int _cached_size_; |
||||
friend void protobuf_AddDesc_route_5fguide_2eproto(); |
||||
friend void protobuf_AssignDesc_route_5fguide_2eproto(); |
||||
friend void protobuf_ShutdownFile_route_5fguide_2eproto(); |
||||
|
||||
void InitAsDefaultInstance(); |
||||
static RouteSummary* default_instance_; |
||||
}; |
||||
// ===================================================================
|
||||
|
||||
|
||||
// ===================================================================
|
||||
|
||||
// Point
|
||||
|
||||
// optional int32 latitude = 1;
|
||||
inline void Point::clear_latitude() { |
||||
latitude_ = 0; |
||||
} |
||||
inline ::google::protobuf::int32 Point::latitude() const { |
||||
// @@protoc_insertion_point(field_get:examples.Point.latitude)
|
||||
return latitude_; |
||||
} |
||||
inline void Point::set_latitude(::google::protobuf::int32 value) { |
||||
|
||||
latitude_ = value; |
||||
// @@protoc_insertion_point(field_set:examples.Point.latitude)
|
||||
} |
||||
|
||||
// optional int32 longitude = 2;
|
||||
inline void Point::clear_longitude() { |
||||
longitude_ = 0; |
||||
} |
||||
inline ::google::protobuf::int32 Point::longitude() const { |
||||
// @@protoc_insertion_point(field_get:examples.Point.longitude)
|
||||
return longitude_; |
||||
} |
||||
inline void Point::set_longitude(::google::protobuf::int32 value) { |
||||
|
||||
longitude_ = value; |
||||
// @@protoc_insertion_point(field_set:examples.Point.longitude)
|
||||
} |
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
// Rectangle
|
||||
|
||||
// optional .examples.Point lo = 1;
|
||||
inline bool Rectangle::has_lo() const { |
||||
return !_is_default_instance_ && lo_ != NULL; |
||||
} |
||||
inline void Rectangle::clear_lo() { |
||||
if (lo_ != NULL) delete lo_; |
||||
lo_ = NULL; |
||||
} |
||||
inline const ::examples::Point& Rectangle::lo() const { |
||||
// @@protoc_insertion_point(field_get:examples.Rectangle.lo)
|
||||
return lo_ != NULL ? *lo_ : *default_instance_->lo_; |
||||
} |
||||
inline ::examples::Point* Rectangle::mutable_lo() { |
||||
|
||||
if (lo_ == NULL) { |
||||
lo_ = new ::examples::Point; |
||||
} |
||||
// @@protoc_insertion_point(field_mutable:examples.Rectangle.lo)
|
||||
return lo_; |
||||
} |
||||
inline ::examples::Point* Rectangle::release_lo() { |
||||
|
||||
::examples::Point* temp = lo_; |
||||
lo_ = NULL; |
||||
return temp; |
||||
} |
||||
inline void Rectangle::set_allocated_lo(::examples::Point* lo) { |
||||
delete lo_; |
||||
lo_ = lo; |
||||
if (lo) { |
||||
|
||||
} else { |
||||
|
||||
} |
||||
// @@protoc_insertion_point(field_set_allocated:examples.Rectangle.lo)
|
||||
} |
||||
|
||||
// optional .examples.Point hi = 2;
|
||||
inline bool Rectangle::has_hi() const { |
||||
return !_is_default_instance_ && hi_ != NULL; |
||||
} |
||||
inline void Rectangle::clear_hi() { |
||||
if (hi_ != NULL) delete hi_; |
||||
hi_ = NULL; |
||||
} |
||||
inline const ::examples::Point& Rectangle::hi() const { |
||||
// @@protoc_insertion_point(field_get:examples.Rectangle.hi)
|
||||
return hi_ != NULL ? *hi_ : *default_instance_->hi_; |
||||
} |
||||
inline ::examples::Point* Rectangle::mutable_hi() { |
||||
|
||||
if (hi_ == NULL) { |
||||
hi_ = new ::examples::Point; |
||||
} |
||||
// @@protoc_insertion_point(field_mutable:examples.Rectangle.hi)
|
||||
return hi_; |
||||
} |
||||
inline ::examples::Point* Rectangle::release_hi() { |
||||
|
||||
::examples::Point* temp = hi_; |
||||
hi_ = NULL; |
||||
return temp; |
||||
} |
||||
inline void Rectangle::set_allocated_hi(::examples::Point* hi) { |
||||
delete hi_; |
||||
hi_ = hi; |
||||
if (hi) { |
||||
|
||||
} else { |
||||
|
||||
} |
||||
// @@protoc_insertion_point(field_set_allocated:examples.Rectangle.hi)
|
||||
} |
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
// Feature
|
||||
|
||||
// optional string name = 1;
|
||||
inline void Feature::clear_name() { |
||||
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); |
||||
} |
||||
inline const ::std::string& Feature::name() const { |
||||
// @@protoc_insertion_point(field_get:examples.Feature.name)
|
||||
return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); |
||||
} |
||||
inline void Feature::set_name(const ::std::string& value) { |
||||
|
||||
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); |
||||
// @@protoc_insertion_point(field_set:examples.Feature.name)
|
||||
} |
||||
inline void Feature::set_name(const char* value) { |
||||
|
||||
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); |
||||
// @@protoc_insertion_point(field_set_char:examples.Feature.name)
|
||||
} |
||||
inline void Feature::set_name(const char* value, size_t size) { |
||||
|
||||
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), |
||||
::std::string(reinterpret_cast<const char*>(value), size)); |
||||
// @@protoc_insertion_point(field_set_pointer:examples.Feature.name)
|
||||
} |
||||
inline ::std::string* Feature::mutable_name() { |
||||
|
||||
// @@protoc_insertion_point(field_mutable:examples.Feature.name)
|
||||
return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); |
||||
} |
||||
inline ::std::string* Feature::release_name() { |
||||
|
||||
return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); |
||||
} |
||||
inline void Feature::set_allocated_name(::std::string* name) { |
||||
if (name != NULL) { |
||||
|
||||
} else { |
||||
|
||||
} |
||||
name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name); |
||||
// @@protoc_insertion_point(field_set_allocated:examples.Feature.name)
|
||||
} |
||||
|
||||
// optional .examples.Point location = 2;
|
||||
inline bool Feature::has_location() const { |
||||
return !_is_default_instance_ && location_ != NULL; |
||||
} |
||||
inline void Feature::clear_location() { |
||||
if (location_ != NULL) delete location_; |
||||
location_ = NULL; |
||||
} |
||||
inline const ::examples::Point& Feature::location() const { |
||||
// @@protoc_insertion_point(field_get:examples.Feature.location)
|
||||
return location_ != NULL ? *location_ : *default_instance_->location_; |
||||
} |
||||
inline ::examples::Point* Feature::mutable_location() { |
||||
|
||||
if (location_ == NULL) { |
||||
location_ = new ::examples::Point; |
||||
} |
||||
// @@protoc_insertion_point(field_mutable:examples.Feature.location)
|
||||
return location_; |
||||
} |
||||
inline ::examples::Point* Feature::release_location() { |
||||
|
||||
::examples::Point* temp = location_; |
||||
location_ = NULL; |
||||
return temp; |
||||
} |
||||
inline void Feature::set_allocated_location(::examples::Point* location) { |
||||
delete location_; |
||||
location_ = location; |
||||
if (location) { |
||||
|
||||
} else { |
||||
|
||||
} |
||||
// @@protoc_insertion_point(field_set_allocated:examples.Feature.location)
|
||||
} |
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
// RouteNote
|
||||
|
||||
// optional .examples.Point location = 1;
|
||||
inline bool RouteNote::has_location() const { |
||||
return !_is_default_instance_ && location_ != NULL; |
||||
} |
||||
inline void RouteNote::clear_location() { |
||||
if (location_ != NULL) delete location_; |
||||
location_ = NULL; |
||||
} |
||||
inline const ::examples::Point& RouteNote::location() const { |
||||
// @@protoc_insertion_point(field_get:examples.RouteNote.location)
|
||||
return location_ != NULL ? *location_ : *default_instance_->location_; |
||||
} |
||||
inline ::examples::Point* RouteNote::mutable_location() { |
||||
|
||||
if (location_ == NULL) { |
||||
location_ = new ::examples::Point; |
||||
} |
||||
// @@protoc_insertion_point(field_mutable:examples.RouteNote.location)
|
||||
return location_; |
||||
} |
||||
inline ::examples::Point* RouteNote::release_location() { |
||||
|
||||
::examples::Point* temp = location_; |
||||
location_ = NULL; |
||||
return temp; |
||||
} |
||||
inline void RouteNote::set_allocated_location(::examples::Point* location) { |
||||
delete location_; |
||||
location_ = location; |
||||
if (location) { |
||||
|
||||
} else { |
||||
|
||||
} |
||||
// @@protoc_insertion_point(field_set_allocated:examples.RouteNote.location)
|
||||
} |
||||
|
||||
// optional string message = 2;
|
||||
inline void RouteNote::clear_message() { |
||||
message_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); |
||||
} |
||||
inline const ::std::string& RouteNote::message() const { |
||||
// @@protoc_insertion_point(field_get:examples.RouteNote.message)
|
||||
return message_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); |
||||
} |
||||
inline void RouteNote::set_message(const ::std::string& value) { |
||||
|
||||
message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value); |
||||
// @@protoc_insertion_point(field_set:examples.RouteNote.message)
|
||||
} |
||||
inline void RouteNote::set_message(const char* value) { |
||||
|
||||
message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value)); |
||||
// @@protoc_insertion_point(field_set_char:examples.RouteNote.message)
|
||||
} |
||||
inline void RouteNote::set_message(const char* value, size_t size) { |
||||
|
||||
message_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), |
||||
::std::string(reinterpret_cast<const char*>(value), size)); |
||||
// @@protoc_insertion_point(field_set_pointer:examples.RouteNote.message)
|
||||
} |
||||
inline ::std::string* RouteNote::mutable_message() { |
||||
|
||||
// @@protoc_insertion_point(field_mutable:examples.RouteNote.message)
|
||||
return message_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); |
||||
} |
||||
inline ::std::string* RouteNote::release_message() { |
||||
|
||||
return message_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); |
||||
} |
||||
inline void RouteNote::set_allocated_message(::std::string* message) { |
||||
if (message != NULL) { |
||||
|
||||
} else { |
||||
|
||||
} |
||||
message_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), message); |
||||
// @@protoc_insertion_point(field_set_allocated:examples.RouteNote.message)
|
||||
} |
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
// RouteSummary
|
||||
|
||||
// optional int32 point_count = 1;
|
||||
inline void RouteSummary::clear_point_count() { |
||||
point_count_ = 0; |
||||
} |
||||
inline ::google::protobuf::int32 RouteSummary::point_count() const { |
||||
// @@protoc_insertion_point(field_get:examples.RouteSummary.point_count)
|
||||
return point_count_; |
||||
} |
||||
inline void RouteSummary::set_point_count(::google::protobuf::int32 value) { |
||||
|
||||
point_count_ = value; |
||||
// @@protoc_insertion_point(field_set:examples.RouteSummary.point_count)
|
||||
} |
||||
|
||||
// optional int32 feature_count = 2;
|
||||
inline void RouteSummary::clear_feature_count() { |
||||
feature_count_ = 0; |
||||
} |
||||
inline ::google::protobuf::int32 RouteSummary::feature_count() const { |
||||
// @@protoc_insertion_point(field_get:examples.RouteSummary.feature_count)
|
||||
return feature_count_; |
||||
} |
||||
inline void RouteSummary::set_feature_count(::google::protobuf::int32 value) { |
||||
|
||||
feature_count_ = value; |
||||
// @@protoc_insertion_point(field_set:examples.RouteSummary.feature_count)
|
||||
} |
||||
|
||||
// optional int32 distance = 3;
|
||||
inline void RouteSummary::clear_distance() { |
||||
distance_ = 0; |
||||
} |
||||
inline ::google::protobuf::int32 RouteSummary::distance() const { |
||||
// @@protoc_insertion_point(field_get:examples.RouteSummary.distance)
|
||||
return distance_; |
||||
} |
||||
inline void RouteSummary::set_distance(::google::protobuf::int32 value) { |
||||
|
||||
distance_ = value; |
||||
// @@protoc_insertion_point(field_set:examples.RouteSummary.distance)
|
||||
} |
||||
|
||||
// optional int32 elapsed_time = 4;
|
||||
inline void RouteSummary::clear_elapsed_time() { |
||||
elapsed_time_ = 0; |
||||
} |
||||
inline ::google::protobuf::int32 RouteSummary::elapsed_time() const { |
||||
// @@protoc_insertion_point(field_get:examples.RouteSummary.elapsed_time)
|
||||
return elapsed_time_; |
||||
} |
||||
inline void RouteSummary::set_elapsed_time(::google::protobuf::int32 value) { |
||||
|
||||
elapsed_time_ = value; |
||||
// @@protoc_insertion_point(field_set:examples.RouteSummary.elapsed_time)
|
||||
} |
||||
|
||||
|
||||
class RouteGuide final { |
||||
public: |
||||
class Stub final : public ::grpc::InternalStub { |
||||
public: |
||||
::grpc::Status GetFeature(::grpc::ClientContext* context, const ::examples::Point& request, ::examples::Feature* response); |
||||
::grpc::ClientAsyncResponseReader< ::examples::Feature>* GetFeature(::grpc::ClientContext* context, const ::examples::Point& request, ::grpc::CompletionQueue* cq, void* tag); |
||||
::grpc::ClientReader< ::examples::Feature>* ListFeatures(::grpc::ClientContext* context, const ::examples::Rectangle& request); |
||||
::grpc::ClientAsyncReader< ::examples::Feature>* ListFeatures(::grpc::ClientContext* context, const ::examples::Rectangle& request, ::grpc::CompletionQueue* cq, void* tag); |
||||
::grpc::ClientWriter< ::examples::Point>* RecordRoute(::grpc::ClientContext* context, ::examples::RouteSummary* response); |
||||
::grpc::ClientAsyncWriter< ::examples::Point>* RecordRoute(::grpc::ClientContext* context, ::examples::RouteSummary* response, ::grpc::CompletionQueue* cq, void* tag); |
||||
::grpc::ClientReaderWriter< ::examples::RouteNote, ::examples::RouteNote>* RouteChat(::grpc::ClientContext* context); |
||||
::grpc::ClientAsyncReaderWriter< ::examples::RouteNote, ::examples::RouteNote>* RouteChat(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag); |
||||
}; |
||||
static Stub* NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel); |
||||
|
||||
class Service : public ::grpc::SynchronousService { |
||||
public: |
||||
Service() : service_(nullptr) {} |
||||
virtual ~Service(); |
||||
virtual ::grpc::Status GetFeature(::grpc::ServerContext* context, const ::examples::Point* request, ::examples::Feature* response); |
||||
virtual ::grpc::Status ListFeatures(::grpc::ServerContext* context, const ::examples::Rectangle* request, ::grpc::ServerWriter< ::examples::Feature>* writer); |
||||
virtual ::grpc::Status RecordRoute(::grpc::ServerContext* context, ::grpc::ServerReader< ::examples::Point>* reader, ::examples::RouteSummary* response); |
||||
virtual ::grpc::Status RouteChat(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::examples::RouteNote, ::examples::RouteNote>* stream); |
||||
::grpc::RpcService* service() override final; |
||||
private: |
||||
::grpc::RpcService* service_; |
||||
}; |
||||
class AsyncService final : public ::grpc::AsynchronousService { |
||||
public: |
||||
explicit AsyncService(::grpc::CompletionQueue* cq); |
||||
~AsyncService() {}; |
||||
void RequestGetFeature(::grpc::ServerContext* context, ::examples::Point* request, ::grpc::ServerAsyncResponseWriter< ::examples::Feature>* response, ::grpc::CompletionQueue* cq, void *tag); |
||||
void RequestListFeatures(::grpc::ServerContext* context, ::examples::Rectangle* request, ::grpc::ServerAsyncWriter< ::examples::Feature>* writer, ::grpc::CompletionQueue* cq, void *tag); |
||||
void RequestRecordRoute(::grpc::ServerContext* context, ::grpc::ServerAsyncReader< ::examples::RouteSummary, ::examples::Point>* reader, ::grpc::CompletionQueue* cq, void *tag); |
||||
void RequestRouteChat(::grpc::ServerContext* context, ::grpc::ServerAsyncReaderWriter< ::examples::RouteNote, ::examples::RouteNote>* stream, ::grpc::CompletionQueue* cq, void *tag); |
||||
}; |
||||
}; |
||||
|
||||
// @@protoc_insertion_point(namespace_scope)
|
||||
|
||||
} // namespace examples
|
||||
|
||||
#ifndef SWIG |
||||
namespace google { |
||||
namespace protobuf { |
||||
|
||||
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
#endif // SWIG
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
#endif // PROTOBUF_route_5fguide_2eproto__INCLUDED
|
@ -0,0 +1,91 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#include <iostream> |
||||
#include <memory> |
||||
#include <string> |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc++/channel_arguments.h> |
||||
#include <grpc++/channel_interface.h> |
||||
#include <grpc++/client_context.h> |
||||
#include <grpc++/create_channel.h> |
||||
#include <grpc++/status.h> |
||||
#include "helloworld.pb.h" |
||||
|
||||
using grpc::ChannelArguments; |
||||
using grpc::ChannelInterface; |
||||
using grpc::ClientContext; |
||||
using grpc::Status; |
||||
using helloworld::HelloRequest; |
||||
using helloworld::HelloReply; |
||||
using helloworld::Greeter; |
||||
|
||||
class GreeterClient { |
||||
public: |
||||
GreeterClient(std::shared_ptr<ChannelInterface> channel) |
||||
: stub_(Greeter::NewStub(channel)) {} |
||||
|
||||
std::string SayHello(const std::string& user) { |
||||
HelloRequest request; |
||||
request.set_name(user); |
||||
HelloReply reply; |
||||
ClientContext context; |
||||
|
||||
Status status = stub_->sayHello(&context, request, &reply); |
||||
if (status.IsOk()) { |
||||
return reply.message(); |
||||
} else { |
||||
return "Rpc failed"; |
||||
} |
||||
} |
||||
|
||||
void Shutdown() { stub_.reset(); } |
||||
|
||||
private: |
||||
std::unique_ptr<Greeter::Stub> stub_; |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
grpc_init(); |
||||
|
||||
GreeterClient greeter( |
||||
grpc::CreateChannel("localhost:50051", ChannelArguments())); |
||||
std::string user("world"); |
||||
std::string reply = greeter.SayHello(user); |
||||
std::cout << "Greeter received: " << reply << std::endl; |
||||
|
||||
greeter.Shutdown(); |
||||
|
||||
grpc_shutdown(); |
||||
} |
@ -0,0 +1,84 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#include <iostream> |
||||
#include <memory> |
||||
#include <string> |
||||
#include <thread> |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc++/server.h> |
||||
#include <grpc++/server_builder.h> |
||||
#include <grpc++/server_context.h> |
||||
#include <grpc++/status.h> |
||||
#include "helloworld.pb.h" |
||||
|
||||
using grpc::Server; |
||||
using grpc::ServerBuilder; |
||||
using grpc::ServerContext; |
||||
using grpc::Status; |
||||
using helloworld::HelloRequest; |
||||
using helloworld::HelloReply; |
||||
using helloworld::Greeter; |
||||
|
||||
class GreeterServiceImpl final : public Greeter::Service { |
||||
Status sayHello(ServerContext* context, const HelloRequest* request, |
||||
HelloReply* reply) override { |
||||
std::string prefix("Hello "); |
||||
reply->set_message(prefix + request->name()); |
||||
return Status::OK; |
||||
} |
||||
}; |
||||
|
||||
void RunServer() { |
||||
std::string server_address("0.0.0.0:50051"); |
||||
GreeterServiceImpl service; |
||||
|
||||
ServerBuilder builder; |
||||
builder.AddPort(server_address); |
||||
builder.RegisterService(&service); |
||||
std::unique_ptr<Server> server(builder.BuildAndStart()); |
||||
std::cout << "Server listening on " << server_address << std::endl; |
||||
while (true) { |
||||
std::this_thread::sleep_for(std::chrono::seconds(5)); |
||||
} |
||||
} |
||||
|
||||
int main(int argc, char** argv) { |
||||
grpc_init(); |
||||
|
||||
RunServer(); |
||||
|
||||
grpc_shutdown(); |
||||
return 0; |
||||
} |
Loading…
Reference in new issue