###############
Getting Started
###############

This guide will help you get started with the Envision Streaming Server.

There are 3 main parts of the Visualization Streamer:

  1. **VizStreamer Service** - A server application with a gRPC interface capable of receiving CAE display data and 
     streaming it to the *Stream Model* client model.
  2. **Server Application** - An application pushing data to the *VizStreamer Service*.
  3. **Client Application** - A |ProductName| client-side app with the StreamModel capable of rendering the 3D 
     models sent from the *VizStreamer Service*. The :js:mod:`cee.vs` module contains all the relevant classes. 
     Please see the :js:class:`documentation for ServerSession <cee.vs.ServerSession>` to get you started with the client-side. 

************************
VizStreamer Service
************************

The VizStreamer Service application is provided as part of the |ProductName| distribution.

In the folder: `server/vsServer/bin` you will find the executable files for the 4 supported platforms (Windows, Linux, 
Mac (ARM and Intel)).

To start the service, run the executable file for your platform.

The default port for the gRPC server is localhost:50051. If you want to change it, you can provide the 
"-a <address>:<port>" argument when starting the service.

**Note:** You need a license for |ProductName| to run the server. This license can be provided via command line options or 
environment variables. See the page :doc:`License <../license>` for more information.

**Example:**

::

    ./VsServiceGrpc -a localhost:12345
    

************************
Server Application
************************

You need an application that will feed the VizStreamer Service with data to show in the client application. 

We have provided several examples of this in the folder: `server/VsServer/Examples`. Here you find examples for C++, C#, 
Python and Node.js.

To run the C++ example, you need to build the example first. In the folder `server/VsServer/Examples/MinimalGrpcProxy` 
you find a simple example that sends a simple model (quad + triangle) to the VizStreamer Service. To build the example, 
you need to have CMake installed.  

**Example:**

::

    cd server/VsServer/Examples/MinimalGrpcProxy
    mkdir build
    cd build
    cmake ..
    make

    ./MinimalGrpcProxy

If you have the server running, you should see the following output:

::
    
    Running MinimalAppGrpcProxy
    Trying to connect to service at: localhost:50051
    - Proxy has connected to service
    - Alive response: Server is alive at: 2025-01-31 12:16:55

    - Pushing a quad and triangle to the server...
    - Create a frame and publish it...
    - Done!

    Press any key to shutdown the proxy and exit    


************************
Client-side Model
************************

You need a web application to show the model provided from the VizStreamer Service. The VizStreamer specific classes for the client can be found in the :js:mod:`cee.vs` module. Here are the necessary classes to get you started: 

    -   :js:class:`ServerSession <cee.vs.ServerSession>`: To connect with the VizStreamer Service, an instance of the ServerSession object needs to be created.
    -   :js:class:`StreamModel <cee.vs.StreamModel>`: A client-side model that needs to be created from a stream in the Service. 
    -   :js:class:`~cee.CloudSession`: Applications will typically create a single instance of 
        CloudSession for managing viewers. It also handles the `animationFrameCallback` which is essential for Envision to update and control animations.
    -   :js:class:`~cee.Viewer`: Handles the canvas, views, picking and other view related functions.   

We provide a minimal example of this in the distribution folder `Examples/MinimalVsClient`. 
This example is a simple web application that connects to the VizStreamer Service and shows the model. If you open the `Examples/MinimalVsClient/index.html` file in a web browser, 
you should see the current model in the first stream of the Service.

It will connect to the VizStreamer Service REST endpoint, default on `localhost:8080`. If you want to change it, 
you can edit the `createAppInstance()` method and provide another address.

