Avatar JD icon Avatar JD — 3D Avatar JD simulator with bidirectional servo sync, action sequencing, $SIM_ scripting, EZ-B emulator support and pose/movement visualization Try it →
 

Net

Talk to the network: download a web page or call a web service (HTTP GET), post data to one (HTTP POST), check whether the internet can be reached, and send UDP messages to other devices.

The HTTP and UDP commands are written as in the C# behind them, Net.HTTPGet. The editor suggests Net.hTTPGet, because JavaScript names start lower case; both spellings work.

Where to find it: type Net. in a JavaScript script, or open the ARCx API view of the script editor and expand Net


Commands

Command What it does
Net.HTTPGet Downloads a web address with an HTTP GET and returns it as text.
Net.HTTPPost Sends form data to a web address with an HTTP POST and returns the server's reply.
Net.isInternetAvailable Checks whether ARCx can reach the Synthiam website, as a test of the internet connection.
Net.sendUDP Sends bytes as one UDP packet to a computer or device on the network.

Details

Net.HTTPGet

Downloads a web address with an HTTP GET and returns it as text. Waits up to 2 seconds, and raises an error if the server cannot be reached, answers with an error or takes too long.

Net.HTTPGet(url)
Net.HTTPGet(url, timeout)
Value Type What it is
url string The web address, starting with http:// or https://.
timeout number Optional. How long to wait for the reply, in milliseconds.

Gives back: string. The text of the server's reply.

Net.HTTPPost

Sends form data to a web address with an HTTP POST and returns the server's reply. Waits up to 2 seconds, and raises an error if the server cannot be reached, answers with an error or takes too long.

Net.HTTPPost(url, postData)
Net.HTTPPost(url, postData, timeout)
Net.HTTPPost(url, postData, timeout, headerNames, headerValues)
Value Type What it is
url string The web address, starting with http:// or https://.
postData string The data to send, form encoded, such as name=Bob&age=5.
timeout number Optional. How long to wait for the reply, in milliseconds.
headerNames string[] Optional. The names of the headers to add, such as Authorization.
headerValues string[] Optional. The value of each header, in the same order as the names.

Gives back: string. The text of the server's reply.

Net.isInternetAvailable

Checks whether ARCx can reach the Synthiam website, as a test of the internet connection. Waits for the reply, up to 4 seconds by default.

Net.isInternetAvailable()

Gives back: boolean. Whether the internet can be reached.

Net.sendUDP

Sends bytes as one UDP packet to a computer or device on the network. It does not wait for a reply or confirm that the packet arrived.

Net.sendUDP(hostname, port, byteArray)
Value Type What it is
hostname string The name or IP address of the computer or device to send to.
port number The UDP port number on the receiving end.
byteArray number[] The bytes to send, each 0 to 255.

Gives back: number. The number of bytes sent.