This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function main() returns error? { | |
RouteGuideClient ep = check new ("http://localhost:8980"); | |
RouteNote[] routeNotes = [ | |
{location: {latitude: 406109563, longitude: -742186778}, message: "m1"}, | |
{location: {latitude: 411733222, longitude: -744228360}, message: "m2"} | |
]; | |
RouteChatStreamingClient routeClient = check ep->RouteChat(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service "RouteGuide" on new grpc:Listener(8980) { | |
remote function RouteChat(RouteGuideRouteNoteCaller caller, | |
stream<RouteNote, grpc:Error?> clientNotesStream) returns error? { | |
check clientNotesStream.forEach(function(RouteNote receivedNote) { | |
string pointKey = keyFromPoint(receivedNote.location); | |
lock { | |
RouteNote[]? routeNotes = ROUTE_NOTES_MAP[pointKey]; | |
if routeNotes is RouteNote[] { | |
foreach RouteNote sendNote in routeNotes { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service RouteGuide { | |
rpc RouteChat(stream RouteNote) returns (stream RouteNote) {} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RouteGuideClient ep = check new ("http://localhost:8980"); | |
// Client streaming | |
Point[] points = [ | |
{latitude: 406109563, longitude: -742186778}, | |
{latitude: 411733222, longitude: -744228360} | |
]; | |
RecordRouteStreamingClient recordRouteStrmClient = check ep->RecordRoute(); | |
foreach Point p in points { | |
check recordRouteStrmClient->sendPoint(p); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service "RouteGuide" on new grpc:Listener(8980) { | |
remote function RecordRoute(stream<Point, grpc:Error?> clientStream) returns RouteSummary|error { | |
Point? lastPoint = (); | |
int pointCount = 0; | |
int featureCount = 0; | |
int distance = 0; | |
decimal startTime = time:monotonicNow(); | |
error? e = clientStream.forEach(function(Point p) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service RouteGuide { | |
rpc RecordRoute(stream Point) returns (RouteSummary) {} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RouteGuideClient ep = check new ("http://localhost:8980"); | |
// Server streaming | |
Rectangle rectangle = { | |
lo: {latitude: 400000000, longitude: -750000000}, | |
hi: {latitude: 420000000, longitude: -730000000} | |
}; | |
stream<Feature, grpc:Error?> features = check ep->ListFeatures(rectangle); | |
error? e = features.forEach(function(Feature f) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service "RouteGuide" on new grpc:Listener(8980) { | |
remote function ListFeatures(Rectangle rectangle) returns stream<Feature, grpc:Error?>|error { | |
int left = int:min(rectangle.lo.longitude, rectangle.hi.longitude); | |
int right = int:max(rectangle.lo.longitude, rectangle.hi.longitude); | |
int top = int:max(rectangle.lo.latitude, rectangle.hi.latitude); | |
int bottom = int:min(rectangle.lo.latitude, rectangle.hi.latitude); | |
Feature[] selectedFeatures = from var feature in FEATURES | |
where feature.name != "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service RouteGuide { | |
rpc ListFeatures(Rectangle) returns (stream Feature) {} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RouteGuideClient ep = check new ("http://localhost:8980"); | |
Feature feature = check ep->GetFeature({latitude: 406109563, longitude: -742186778}); | |
io:println(`GetFeature: lat=${feature.location.latitude}, lon=${feature.location.longitude}`); |
NewerOlder