Menu
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.

Initializing a Client Session

When the XStxIServerManagerListenerFcnServerInitialize event fires it returns a handle to an XStxServer object. This is the object that your application uses to communicate with the client: streaming audio and video output and receiving user input and client messages. Your implementation of a XStxIServerManagerListenerFcnServerInitialize callback function should initialize the XStxServer object, register event sinks for the IServerListener events, and set the audio source by calling the XStxServerSetVideoSource function. Setting the audio source by calling the XStxServerSetAudioSource function is optional; for more information, see Streaming Audio to a Client.

This excerpt from ServerManagerListener.cpp shows how to initialize the XStxServer object. The file is in the <SDK_dir>\example_src\server\common directory.

Copy
XStxResult ServerManagerListenerImp::XStxIServerManagerListenerServerInitialize( XStxServerHandle server, uint32_t timeout, const char* applicationContext) { if (mServerToInfoMap.find(server) != mServerToInfoMap.end()) { return XSTX_RESULT_ALREADY_CREATED; } XStxResult result = XSTX_RESULT_OK; /** Create an object to hold on to server specific info */ ServerInfo* info = new ServerInfo(); XStxIServerListener* listener = NULL; info->mApp = NULL; info->mServer = server; /** Instantiate the hosted application */ result = HostedApplication::createHostedApplication( server, applicationContext, mServerContext, info->mApp); if (result != XSTX_RESULT_OK) { goto exit; } /** Point the app to the server and start the app */ result = info->mApp->setServer(info->mServer); if (result != XSTX_RESULT_OK) { goto exit; } result = info->mApp->start(); if (result != XSTX_RESULT_OK) { goto exit; } /** Point the server to the app and start the server */ listener = info->mApp->getServerListener(); if ( NULL != listener ) { XSTX_CALLBACK_NOT_NULL_OR_ERROR(listener, ServerReady); XSTX_CALLBACK_NOT_NULL_OR_ERROR(listener, ServerStopped); XSTX_CALLBACK_NOT_NULL_OR_ERROR(listener, MessageReceived); } result = XStxServerSetListener( info->mServer, listener); if (result != XSTX_RESULT_OK) { goto exit; } result = XStxServerSetInputSink( info->mServer, info->mApp->getInputSink()); if (result != XSTX_RESULT_OK) { goto exit; } #ifdef APPLICATION_CAPTURES_AUDIO //The example audio source does provides timestamps result = XStxServerSetAudioSource( info->mServer, info->mApp->getAudioSource(), true); if (result != XSTX_RESULT_OK) { goto exit; } #endif //need to manually change the isProvidingTimestamp flag here to false //if it doesn't provide timestamp result = XStxServerSetVideoSource( info->mServer, info->mApp->getVideoSource(), true); if (result != XSTX_RESULT_OK) { goto exit; } mServerToInfoMap[server] = info; return XSTX_RESULT_OK; exit: if (info != NULL) { delete info->mApp; XStxServerRecycle(info->mServer); delete info; } return result; }