14 """A client that makes both Greeter and RouteGuide RPCs."""
16 from __future__
import print_function
24 import helloworld_pb2_grpc
25 import route_guide_pb2
26 import route_guide_pb2_grpc
27 import route_guide_resources
37 feature = route_guide_stub.GetFeature(point)
38 if not feature.location:
39 print(
"Server returned incomplete feature")
43 print(
"Feature called %s at %s" % (feature.name, feature.location))
45 print(
"Found no feature at %s" % feature.location)
60 print(
"Looking for features between 40, -75 and 42, -73")
62 features = route_guide_stub.ListFeatures(rectangle)
64 for feature
in features:
65 print(
"Feature called %s at %s" % (feature.name, feature.location))
69 for _
in range(0, 10):
70 random_feature = feature_list[random.randint(0,
len(feature_list) - 1)]
71 print(
"Visiting point %s" % random_feature.location)
72 yield random_feature.location
73 time.sleep(random.uniform(0.5, 1.5))
80 route_summary = route_guide_stub.RecordRoute(route_iterator)
81 print(
"Finished trip with %s points " % route_summary.point_count)
82 print(
"Passed %s features " % route_summary.feature_count)
83 print(
"Travelled %s meters " % route_summary.distance)
84 print(
"It took %s seconds " % route_summary.elapsed_time)
96 print(
"Sending %s at %s" % (msg.message, msg.location))
98 time.sleep(random.uniform(0.5, 1.0))
103 for response
in responses:
104 print(
"Received message %s at %s" %
105 (response.message, response.location))
115 greeter_response = greeter_stub.SayHello(
117 print(
"Greeter client received: " + greeter_response.message)
118 print(
"-------------- GetFeature --------------")
120 print(
"-------------- ListFeatures --------------")
122 print(
"-------------- RecordRoute --------------")
124 print(
"-------------- RouteChat --------------")
128 if __name__ ==
'__main__':
129 logging.basicConfig()