roNodeJs

roNodeJs is a BrightScript object that allows the launching of a Node.js® instance. These Node.js instances will have access to all BrightSign Node.js modules as built in modules. roNodeJs also provides mechanisms to communicate between JavaScript and BrightScript environments for more complex applications.

Object Creation

roNodeJs is instantiated with a filename and optional parameters. 

node = CreateObject("roNodeJs", "index.js", {message_port:my_message_port, arguments: ["arg1", "arg2"]})

In OS 8.2.17 and later versions, you can also pass an optional node_arguments parameter which provides arguments to the node interpreter itself (as opposed to arguments which provides arguments to the JavaScript application being run inside Node):

node = CreateObject("roNodeJs", "index.js", {message_port:my_message_port, node_arguments: ["arg"], arguments: ["arg1", "arg2"]})
  • message_port: Optional. Allows communication with JavaScript applications. 

  • arguments: Optional. Passes arguments to the node instance. 

  • node_arguments: Optional. Passes arguments to the node.js executable, for example, to enable remote inspector for node.js. Node_arguments can take multiple arguments.

  • env_vars: Optional. Passes environment variables (supplied as an associative array) to the node.js application. Note: Environment variable names are case-sensitive, but roAssociativeArray is case-insensitive by default and the BrightScript literal syntax for associative arrays forces all key names to lower case. To ensure correct behavior, call SetModeCaseSensitive() and use the AddReplace() method to add variables to the array. Or you can use the following example, which is slightly less verbose than AddReplace():

a={} a.SetModeCaseSensitive() a["KeY"] = 1 a["key"] = 2 print a ' returns both key and KeY

PostJsMessage()

PostJsMessage (data as AssociativeArray) As Boolean
Posts a collection of key:value pairs to the BrightScript MessagePort JavaScript class. This method takes an associative array but it doesn't support nested associative arrays. See JavaScript to BrightScript for more details.

roNodeJs Events

See this page for information about roNodeJs events.

Examples

To enable inspector using node_arguments:

To change a directory to the directory of the current JavaScript file:

To set a timer to stop node from exiting:

ON THIS PAGE

To pass arguments to roNodeJs:

Note that "node_arguments" are arguments that come before the filename, while "arguments" come after the filename.