Node: TCP
The TCP node allows you to create a generic TCP connection to another device on the network, and manage the connection yourself. You can send messages on demand, and can process received messages to implement your own custom behavior. The TCP node is useful for situations where Waltz does not provide a node for the specific device you are using, but you would still like to be able to communicate with that device.
Contents
Settings
Expected Type | Details | Default | |
---|---|---|---|
localInterface
|
LocalInterface | The local network adapter that will be used to communicate with the remote device. | LocalInterface("0.0.0.0")
|
remoteAddress
|
RemoteAddress/IP | The address of the remote device. | IP("10.10.1.1", 10000)
|
messageSeparator
|
String | A String that is used to delineate between incoming messages over the TCP connection. If left blank, message data is delivered as it is read, with no guarantee that a full packet will be received, or that multiple packets won't be provided in the same callback. An unlimited number of characters can be used to separate messages, but keep in mind that Waltz will cache incoming data until it encounters the separator. | "\n"
|
callback
|
Any | A script in which a single additional variable, message, is present containing the message to be processed. | print(message);
|
Parameters
There are no parameters exposed by this node. Each received message is processed by the script defined as the callback
.
Functions
Arguments | Returns | Details | |
---|---|---|---|
send(message)
|
String message - The message you wish to send to the device.
|
Void | Send the specified message to the device. Be sure to include any necessary message terminators for your device, like \n or \n\r .
|
Example Usage
Splitting values from messages
You may find that the remote device has additional delineation within messages that are sent to you. While you delineate messages using the messageSeparator you define, the data within the message may also need separated. For example, suppose you receive a message that reads SET,07,1994
, you may want to break the parts of that message apart.
This can be accomplished in a callback as follows:
var values = message.split(","); var command = values[0]; // Will be SET var thing = ParseInt(values[1]); // Will be 7 var value = ParseInt(values[2]); // Will be 1994
You could then define your own logic based on the command
, thing
, and value
properties we extracted from the message.
Nodes | |
---|---|
Devices | ArtNet Input · ArtNet Output · Interactive LED Processor · NDI™ Input · NDI™ Output · OSC Input · OSC Output · Projector · SensorLink · TCP · TUIO Output · UDP Input · UDP Output · Watchout Media Server |
Objects | LED Tile Layout · List · Map · Random Number · Simulated Touch · Timer · Value · Wave |
Operators | Blend · Change · Clip · Cluster Tracker · DMX Multiverse Merge · Ease · Filter · Hold · JSON Mapper · JSON Stringify · Logic · Math · Proximity · Range · Rotate · Scale · Shear · Smooth · Touch Mapper · Translate |
Scenes | External Scene · Material Scene |
Materials | Graph · Touch Material |
Scripting | Script Function · Script |
Comments | Comment |