
############
CloudSession
############

.. js:class:: cee.CloudSession

   The CloudSession's responsibility is to manage the :js:class:`Viewers <cee.Viewer>` and the main event loop of EnvisionWeb (:js:meth:`handleAnimationFrameCallback <cee.CloudSession.handleAnimationFrameCallback>`\ ).
   
   All EnvisionWeb applications need a CloudSession object. There is only need for one, even in apps with multiple viewers, views, models and remote servers.
   
   
   Index
   =====
   
   .. rubric:: Constructors
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:func:`~cee.CloudSession.constructor`
   
   .. rubric:: Accessors
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:func:`~cee.CloudSession.buildDateTimeString`
   * :js:func:`~cee.CloudSession.version`
   * :js:func:`~cee.CloudSession.viewerCount`
   
   .. rubric:: Methods
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:meth:`~cee.CloudSession.addModelToProcessingSet`
   * :js:meth:`~cee.CloudSession.addViewer`
   * :js:meth:`~cee.CloudSession.deleteAllViewers`
   * :js:meth:`~cee.CloudSession.deleteViewerAt`
   * :js:meth:`~cee.CloudSession.destroySession`
   * :js:meth:`~cee.CloudSession.getViewerArray`
   * :js:meth:`~cee.CloudSession.getViewerAt`
   * :js:meth:`~cee.CloudSession.handleAnimationFrameCallback`
   * :js:meth:`~cee.CloudSession.removeModelFromProcessingSet`
   
   



.. rst-class:: kind-group kind-constructors

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


.. js:method:: cee.CloudSession.constructor

      .. rst-class:: sig-pretty-signature
      
         | CloudSession(): :js:class:`CloudSession <cee.CloudSession>`
      
      Constructor
      
      **Returns**\ : :js:class:`CloudSession <cee.CloudSession>`
      



.. rst-class:: kind-group kind-accessors

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


.. js:method:: cee.CloudSession.buildDateTimeString

      .. rst-class:: sig-pretty-signature
      
         | *get* buildDateTimeString(): *string*
      
      Returns the date and time this version of EnvisionWeb was built
      
      **Returns**\ : *string*
      



.. js:method:: cee.CloudSession.version

      .. rst-class:: sig-pretty-signature
      
         | *get* version(): *string*
      
      Returns the version of HOOPS Envision for Web
      
      Format: Major.Minor.Patch-Build. E.g. '1.2.0+34145A' or '1.2.0-rc1++38C14A
      
      **Returns**\ : *string*
      



.. js:method:: cee.CloudSession.viewerCount

      .. rst-class:: sig-pretty-signature
      
         | *get* viewerCount(): *number*
      
      Returns the number of viewers in the client application.
      
      **Returns**\ : *number*
      



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

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


.. js:method:: cee.CloudSession.addModelToProcessingSet

      .. rst-class:: sig-pretty-signature
      
         | addModelToProcessingSet(**model**\ : :js:class:`ProcessableModel <cee.ProcessableModel>`\ ): *void*
      
      Manually add a model to the set of models that need background processing
      
      **Parameters**
      
      
         **model**\ : :js:class:`ProcessableModel <cee.ProcessableModel>`
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.CloudSession.addViewer

      .. rst-class:: sig-pretty-signature
      
         | addViewer(**canvas**\ : *HTMLCanvasElement*\ , **viewerOptions**\ : :js:class:`ViewerOptions <cee.ViewerOptions>`\ ): :js:class:`Viewer <cee.Viewer>`
      
      Adds a new Viewer to the session.
      
      The Viewer is tied to a HTML Canvas element, and the provided canvas must be capable of rendering WebGL. Returns null if the canvas is not capable of rendering WebGL or if WebGL resources are exhausted.
      
      A Viewer can have many :js:class:`Views <cee.View>`\ , and all the Views within a Viewer can share WebGL resources. So, to show the same Model in two Views, using one Viewer with two Views is more efficient than using two Viewers with one View each.
      
      A client application can contain many Viewers, but each Viewer must be linked to single unique Canvas.
      
      **Parameters**
      
      
         **canvas**\ : *HTMLCanvasElement*
      
         **viewerOptions**\ : :js:class:`ViewerOptions <cee.ViewerOptions>`
      
      
      **Returns**\ : :js:class:`Viewer <cee.Viewer>`
      



.. js:method:: cee.CloudSession.deleteAllViewers

      .. rst-class:: sig-pretty-signature
      
         | deleteAllViewers(): *void*
      
      Deletes all viewers from the app.
      
      **Returns**\ : *void*
      



.. js:method:: cee.CloudSession.deleteViewerAt

      .. rst-class:: sig-pretty-signature
      
         | deleteViewerAt(**index**\ : *number*\ ): *void*
      
      Deletes the viewer at the given index.
      
      The index must be zero based and between 0 and viewerCount - 1
      
      **Parameters**
      
      
         **index**\ : *number*
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.CloudSession.destroySession

      .. rst-class:: sig-pretty-signature
      
         | destroySession(): *void*
      
      Destroys the session object. This will delete all the viewers.
      
      **Returns**\ : *void*
      



.. js:method:: cee.CloudSession.getViewerArray

      .. rst-class:: sig-pretty-signature
      
         | getViewerArray(): readonly  :js:class:`Viewer <cee.Viewer>`\ []
      
      Returns a read only array with all viewers in the session
      
      **Returns**\ : readonly  :js:class:`Viewer <cee.Viewer>`\ []
      



.. js:method:: cee.CloudSession.getViewerAt

      .. rst-class:: sig-pretty-signature
      
         | getViewerAt(**index**\ : *number*\ ): :js:class:`Viewer <cee.Viewer>`
      
      Returns the viewer with the given index.
      
      The index must be zero based and between 0 and viewerCount - 1
      
      **Parameters**
      
      
         **index**\ : *number*
      
      
      **Returns**\ : :js:class:`Viewer <cee.Viewer>`
      



.. js:method:: cee.CloudSession.handleAnimationFrameCallback

      .. rst-class:: sig-pretty-signature
      
         | handleAnimationFrameCallback(**highResTimestamp_ms**\ : *number*\ ): *boolean*
      
      Mandatory update method for the HOOPS Envision Client.
      
      This method must be called from a requestAnimationFrame() for animations to run and server communication to work as expected.
      
      The standard code for doing this is:
      
      .. code-block:: javascript
      
         // Setup timer to keep the session viewer up-to-date
         function myAnimationFrameCallback(highResTimestamp) {
             mySession.handleAnimationFrameCallback(highResTimestamp);
             requestAnimationFrame(myAnimationFrameCallback);
         }
         
         requestAnimationFrame(myAnimationFrameCallback);
      
      **Parameters**
      
      
         **highResTimestamp_ms**\ : *number*
      
      
      **Returns**\ : *boolean*
      



.. js:method:: cee.CloudSession.removeModelFromProcessingSet

      .. rst-class:: sig-pretty-signature
      
         | removeModelFromProcessingSet(**model**\ : :js:class:`ProcessableModel <cee.ProcessableModel>`\ ): *void*
      
      Remove a model that was previously added manually to the processing set
      
      **Parameters**
      
      
         **model**\ : :js:class:`ProcessableModel <cee.ProcessableModel>`
      
      
      **Returns**\ : *void*
      




