Created
June 27, 2019 10:22
-
-
Save germanviscuso/e4231ab43359cdbc50c8462314aba450 to your computer and use it in GitHub Desktop.
Progressive Response in Java
This file contains hidden or 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
sendProgressiveResponseMessage("Please wait!", handlerInput); | |
public static void sendProgressiveResponseMessage(final String message, | |
final HandlerInput handlerInput){ | |
final SpeakDirective speakDirective = SpeakDirective.builder() | |
.withSpeech(message) | |
.build(); | |
final String requestId = handlerInput.getRequestEnvelope().getRequest().getRequestId(); | |
final SendDirectiveRequest sendDirectiveRequest = SendDirectiveRequest.builder() | |
.withDirective(speakDirective) | |
.withHeader(Header.builder().withRequestId(requestId).build()) | |
.build(); | |
handlerInput.getServiceClientFactory().getDirectiveService().enqueue(sendDirectiveRequest); | |
} | |
} |
Nice!! Yes, it's basically the same. Let me know if you manage to "await" :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is my code, quite similar but in Kotlin:
Now the challenge is to make the logic await till the progressive response is done before returning the final response :) Working on it!