/** * Helper method that retrieves the system state from the request context. * @param context request context. * @return SystemState the systemState */ private SystemState getSystemState(Context context) { return context.getState(SystemInterface.class, SystemState.class); } }
@Override public SpeechletRequestEnvelope envelope(final AlexaRequest request) { final SystemState systemState = SystemState.builder() .withUser(session.getUser()) .withDevice(client.device) .withApiEndpoint(client.apiEndpoint) .withApplication(session.getApplication()).build(); final Context context = Context.builder().addState(systemState).build(); // ensure session is ready for another request (make an exception for session ended and launch requests) Validate.isTrue(!sessionClosed || AlexaSessionEndedRequest.class.isInstance(request) || AlexaLaunchRequest.class.isInstance(request), "Session already closed and not ready for another request."); return SpeechletRequestEnvelope.builder() .withRequest(request.getSpeechletRequest()) .withSession(request instanceof AlexaSessionStartedRequest ? getSessionWithIsNew() : session) .withVersion(AlexaClient.VERSION) .withContext(context) .build(); }
/** * Helper method that retrieves the system state from the request context. * @param context request context. * @return SystemState the systemState */ private SystemState getSystemState(Context context) { return context.getState(SystemInterface.class, SystemState.class); }
private String getDisplayStateToken(SpeechletRequestEnvelope envelope) { DisplayState state = envelope.getContext().getState(DisplayInterface.class, DisplayState.class); String stateToken = ""; if (state != null) { stateToken = state.getToken(); } return stateToken; } }
private String getDisplayStateToken(SpeechletRequestEnvelope envelope) { DisplayState state = envelope.getContext().getState(DisplayInterface.class, DisplayState.class); String stateToken = ""; if (state != null) { stateToken = state.getToken(); } return stateToken; } }
public SpeechletResponse dispatchRequest(SpeechletRequestEnvelope envelope) { SystemState system = envelope.getContext().getState(SystemInterface.class, SystemState.class); boolean hasDisplay = system.getDevice().getSupportedInterfaces().isInterfaceSupported(DisplayInterface.class);
public SpeechletResponse dispatchRequest(SpeechletRequestEnvelope envelope) { SystemState system = envelope.getContext().getState(SystemInterface.class, SystemState.class); boolean hasDisplay = system.getDevice().getSupportedInterfaces().isInterfaceSupported(DisplayInterface.class);