V8 Javascript API

RS Class Reference

[Globals]

Description

The main interface from a V8 command into RealityServer. This class provides the primary interface into RealityServer. Every RealityServer command is exposed as a function on the RS class. These can be called directly and their results collected for further processing or returning to the caller. Arguments for the command are passed in an object as the first argument to the function call.

For example to call the 'import_scene' you can simply do the following:

‎ try {
   RS.import_scene(
     {
       scene_name:'my_scene',
       filename:'scenes/crystal.mi',
       block:true
     }
   );
 } catch (e) {
   log.error('Error loading scene crystal.mi');
   throw(e);
 }

In addition the execute function is provided allow access to commands whose names are not legitimate JavaScript identifiers (eg: commands within a namespace). This takes the command name as the first argument. EG:

‎ try {
   // Use execute to call a command.
   RS.execute(
     'import_scene',
     {
       scene_name:'my_scene',
       filename:'scenes/crystal.mi',
       block:true
     }
   );
 } catch (e) {
   log.error('Error loading scene crystal.mi');
   throw(e);
 }
The former format is generally preferred for clarity.

Inner Classes

class 
Helper class to return errors to the user. More...

Static Functions

 Progress( String id, Number value, String area, String message)
Emits an event describing the progress of the command being executed. More...
varying execute( String command_name, Object args)
Executes the command command_name with arguments args. More...

Properties

Object  Configuration
Contains the contents of the RealityServer configuration file (by default realityserver.conf ). More...
Boolean  Tainted
When set to true, command blacklisting and whitelisting will be enabled. More...

Functions

RS.Progress( String id, Number value, String area, String message) [static]

Emits an event describing the progress of the command being executed.

Parameters

id
the id registered when the command was executed. This is typically provided as a parameter to the command to identify individual calls.
value
a 0 to 100 value indicating progress.
area
the area of execution the command is currently in.
message
a message associated with the progress event.
varying RS.execute( String command_name, Object args) [static]

Executes the command command_name with arguments args.

Parameters

command_name
the name of the command to call.
args
object containing the command's argumemts.

Returns

the result from the command. On error and exception will be thrown.

Properties

Object RS.Configuration

Contains the contents of the RealityServer configuration file (by default realityserver.conf ). This property closely mirrors the native mi.rswservices.IConfiguration interface with the following mapping conventions:

Configuration values will translate to their appropriate type:

  • String for string values

  • Number for floating point and 32bit integer numeric values

  • BigInt for 64bit integer values

  • Enumerations are mapped to lowercase strings without their namespace and type prefix. For example the native enum mi.neuraylib.INetwork_configuration.MODE_TCP becomes "tcp" and mi.rswservices.ACCESS_ORDER_INHERITED becomes "inherited".

Configuration properties will be named the same as the native get method used to retrieve it, omitting the get_ prefix. For example the https certificate path retrieved by the native mi.rswservices.IConfiguration.get_https_certificate_file() method will map to the property name https_certificate_file.

Properties at the root of the configuration file become direct root members of RS.Configuration . For example the content_root configuration directive becomes RS.Configuration.content_root.

All iterable configuration items are mapped to arrays. For example url entries retrieved by the native mi.rswservices.IUrl_configuration.get_url() method are added to the RS.Configuration.url[] array. Likewise directory entries retrieved by the native mi.rswservices.IUrl_configuration.get_directory() method are added to the RS.Configuration.directory[] array.

Flag properties become arrays with the enabled flags present in the array as strings. For example RS.Configuration.neuray_configuration.trace_flag may look like this:

‎ ["errtrace", "disktrace"] 

Mime types become objects with extension and mime_type properties and are available via RS.Conguration.mime_type[].

Boolean RS.Tainted

When set to true, command blacklisting and whitelisting will be enabled. Boths lists can be configured via the RealityServer configuration file. By default this value will be set to false, allowing broad access to any command registered to the server. Enabling command blacklisting by setting this value to true is particularly useful when user input can directly influence which commands are executed as is the case with the batch command.