.. role:: clio-static
   :class: clio-flag clio-flag-static


#############
ServerSession
#############

.. js:class:: cee.vs.ServerSession

   A ServerSession object is the first object that needs to be initialized when working with the :js:class:`StreamModel <cee.vs.StreamModel>`\ . It manages the communication with the Visualization Streamer (VizStreamer) service.
   
   The :js:meth:`getAvailableStreams_async <cee.vs.ServerSession.getAvailableStreams_async>` method is used to get the information about all available streams. These streams can be subsequently used to create :js:class:`StreamModel <cee.vs.StreamModel>` instance(s) with the method :js:meth:`createStreamModel <cee.vs.ServerSession.createStreamModel>`\ .
   
   **Example:** Create a ServerSession and a StreamModel from the first available stream.
   
   .. code-block:: typescript
   
      // Connect to the server session at the given url. 
      const serverSession = await cee.vs.ServerSession.createInstance_async("http://localhost:8091");
      // Get the available streams
      const streams = await serverSession.getAvailableStreams_async();
      
      if (streams[0]) {
          const streamId = streams[0].streamId;
          const streamModel = serverSession.createStreamModel(streamId);
      
          // Add the model to the cee.View
          this.view.addModel(streamModel);
          // Start the streaming if not already started.
          if (!streamModel.isStreamingActive()) {
              await streamModel.startStreaming_async();
          }
      }
   
   
   Index
   =====
   
   .. rubric:: Methods
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:meth:`~cee.vs.ServerSession.createStreamModel`
   * :js:meth:`~cee.vs.ServerSession.destroySession`
   * :js:meth:`~cee.vs.ServerSession.getAvailableStreams_async`
   * :js:meth:`~cee.vs.ServerSession.getServerUrl`
   * :js:meth:`~static cee.vs.ServerSession.createInstance_async`
   
   



.. rst-class:: kind-group kind-methods

.. rubric:: Methods
   :class: kind-group-title


.. js:method:: cee.vs.ServerSession.createStreamModel

      .. rst-class:: sig-pretty-signature
      
         | createStreamModel(**streamId**\ : *string*\ ): :js:class:`StreamModel <cee.vs.StreamModel>`
      
      Creates a new :js:class:`StreamModel <cee.vs.StreamModel>` for the given stream id. Streaming of data into the new model is not started by default, but should be initiated by calling :js:meth:`StreamModel.startStreaming_async <cee.vs.StreamModel.startStreaming_async>`\ .
      
      **Parameters**
      
      
         **streamId**\ : *string*
      
      
      **Returns**\ : :js:class:`StreamModel <cee.vs.StreamModel>`
      



.. js:method:: cee.vs.ServerSession.destroySession

      .. rst-class:: sig-pretty-signature
      
         | destroySession(): *void*
      
      Destroys this ServerSession instance.
      
      This will detach all StreamModels from the session and free all resources associated with the session. After calling this method, the ServerSession instance should not be used anymore.
      
      **Returns**\ : *void*
      



.. js:method:: cee.vs.ServerSession.getAvailableStreams_async

      .. rst-class:: sig-pretty-signature
      
         | getAvailableStreams_async(): *Promise*
      
      Gets the information about all the streams available in the VizStreamer Service. Returns a :js:class:`StreamInfo <cee.vs.StreamInfo>` array on success, otherwise throws an error (e.g. connection problems).
      
      **Returns**\ : *Promise*
      



.. js:method:: cee.vs.ServerSession.getServerUrl

      .. rst-class:: sig-pretty-signature
      
         | getServerUrl(): *string*
      
      Gets the url of the HTTP stream server that this ServerSession is connected to.
      
      **Returns**\ : *string*
      



.. js:method:: static cee.vs.ServerSession.createInstance_async

      .. rst-class:: clio-flags
      
         :clio-static:`static`
      
      .. rst-class:: sig-pretty-signature
      
         | createInstance_async(**serverUrl**\ : *string*\ ): *Promise*
      
      Creates a new ServerSession instance.
      
      **Parameters**
      
      
         **serverUrl**\ : *string*
      
      
            The url on which the VizStreamer'sHTTP stream server resides, e.g. ``http://localhost:8091``
      
      
      
      **Returns**\ : *Promise*
      




