Created
August 18, 2021 04:40
-
-
Save daneshk/25a4c04f4095b088f125c0baed488b90 to your computer and use it in GitHub Desktop.
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(); | |
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