Web Sample

After setting up of any of the Cube Samples, you need a website able to make the proper calls to the Genvid API to display the stream and use the game data. It also needs to make specific calls via the Genvid API to interact with your game.

The Web Sample creates a website for you to stream any of the Cube Samples to: DirectX, Unreal, or Unity. It appears as a service on your Cluster UI Jobs page. It includes a CUBE SAMPLE link and a CUBE ADMIN link.

These links redirect you to the website that streams the running DirectX, Unreal, or Unity sample. The CUBE SAMPLE link redirects you as a user while the CUBE ADMIN link redirects you as an administrator.

In order to use it, you need to build it and then load it:

  1. Go to the /samples/cube/web directory.

  2. Build the website.

    py web.py build
    
  3. Load the website.

    py web.py load
    

SSL support on local cluster

It is now possible to generate self-signed SSL certificates for your local cluster when loading the web sample. HashiCorp Vault generates the certificates that will be used in the backend of the Web Sample.

Use the following commands to generate the certificates in /samples/cube/web where the web sample can find them. The commands also create an https link in your Cluster UI Jobs page:

py web.py load --ssl

or

py web.py load -s

Alternatively, you can use the following to only generate the ssl certificates:

genvid-sdk generate-ssl

Whether you’re using the standalone mode or a streaming platform such as Youtube, etc, make sure that your hcl file will contain the new configuration that enables embedding with SSL by setting embed_ssl to true.

config {
   embed_ssl {
      enabled = true
   }
}

Warning

Whether you’re using SSL on a cloud or a local cluster, if you need to load multiple hcl configuration files containing the embed_ssl key, such as twitch.sample.hcl or youtube.sample.hcl, make sure to load them after the web sample is loaded. Otherwise you might overwrite the values associated with the embed_ssl key.

This section covers a step-by-step example on how we created the Web Sample. Feel free to adapt any of our sample code you find useful for your own project.