Eagle 3D Streaming

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 2 Next »

GitHub Link: https://github.com/e3ds/full-html-control/blob/html/ejs-multiApp/tokenServer.js

First, use the following command to clone the repository branch:

git clone -b html/multiApp  --single-branch https://github.com/e3ds/full-html-control

To dynamically set the app name and config, we need to modify the tokenServer.js

app.get("/:appName/:configurationName",

  function (req, res) 
  {
	 
		const appName = req.params.appName; //dynamically receiving app name from url
		const configurationName = req.params.configurationName; //dynamically receiving config name from url
		
		 GenerateStreamingSessionToken(res,false, appName, configurationName) 
		
		
  }
);

Here, we are dynamically receiving appName and configurationName from the URL params. Then we pass the appName and configurationName as parameters to the GenerateStreamingSessionToken function.

Inside the GenerateStreamingSessionToken function, we update streamingAppInfo variable’s appName and configurationName properties.

function GenerateStreamingSessionToken(res,indexCP_dist=false, appName, configurationName) 
{
	streamingAppInfo.core.appName = appName;
	streamingAppInfo.core.configurationName = configurationName;

	const axios = require("axios");	
	
	axios.post(
				"https://token.eaglepixelstreaming.com/api/v1/token/create", 
				{
					"object" : streamingAppInfo,
					"expiry": tokenExpiryDuration,
					"client" : clientUserName
				}, 
				{
				  headers: {"Authorization": "Auth "+apiKey }
				}
	
			 )
			 .then((response) => 
			  {
				//console.dir(response);
				console.log("response.token :" +response.data.token);
				
				if(response.data.error)
					console.log("response.error :" +response.data.error);
	
			
				
				var obj={ 		
								
								
								token: response.data.token,
								clientUserName: clientUserName,
						}
									 
			console.log("obj passing to ejs view :" +  JSON.stringify(obj) );		
			res.render("player", obj);
			
        
      })
	  .catch(err => 
									{
									  console.error(err);
									  console.log(err);
								});	
}
  • No labels