Amazon AppStream
Developer Guide

This documentation is for an older version of Amazon AppStream. For information about the latest version, see the Amazon AppStream 2.0 Developer Guide.

Requesting a New Session from Amazon AppStream

After your entitlement service has verified that the user is authorized to access the application, it calls the entitleSession function of the current Application object to create a new client session for that application. If successful, the function returns the newly created Session object.

The following excerpt from /services/ illustrates how to make this call.

When you call entitleSession, you have the option of passing in binary data using the opaqueData member of the EntitleSessionInput object. If supplied, this data is passed to the application when the new session is created. The format and content of this data is specific to the application. You might use opaqueData, for example, to initialize the client session with state information saved the last time this user connected to your application.

public Session entitleSession(User user, Application application) { Session session; try { EntitleSessionInput entitleSessionInput = new EntitleSessionInput(); // Could optionally pass opaque data to the application that will service the session. // entitleSessionInput.setOpaqueData("some application-specific data"); session = application.entitleSession(entitleSessionInput); } catch (AmazonServiceException e) { // Make the exception just a bit more obvious with an informational message. // It may not be obvious where the error occurred with just a stack trace. if (e.getErrorType().equals(AmazonServiceException.ErrorType.Service)) { log.error("An error occurred in the AppStream service while entitling a session for app: " + application.getId(), e); } throw e; } user.storeSessionId(application.getId(), session.getId()); user.setSessionCount(user.getSessionCount() + 1);; return session; }