Skip to content

Instantly share code, notes, and snippets.

@daneshk
Created August 18, 2021 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daneshk/25a4c04f4095b088f125c0baed488b90 to your computer and use it in GitHub Desktop.
Save daneshk/25a4c04f4095b088f125c0baed488b90 to your computer and use it in GitHub Desktop.
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();
future<error?> f1 = start readResponse(routeClient);
foreach RouteNote n in routeNotes {
check routeClient->sendRouteNote(n);
}
check routeClient->complete();
check wait f1;
}
// read response method to run in a separate worker.
function readResponse(RouteChatStreamingClient routeClient) returns error? {
RouteNote? receiveRouteNote = check routeClient->receiveRouteNote();
while receiveRouteNote != () {
io:println(`Got message '${receiveRouteNote.message}' at lat=${receiveRouteNote.location.latitude},
lon=${receiveRouteNote.location.longitude}`);
receiveRouteNote = check routeClient->receiveRouteNote();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment