WebSocket
The websocket node type send and receives simulation data via binary WebSocket messages.
Prerequisites
This node-type requires libwebsockets (>= 2.3.0).
Implementation
The source code of the node-type is available here: https://github.com/VILLASframework/node/blob/master/lib/nodes/websocket.cpp
Configuration
By default the villas node daemon listens on http.port for HTTP and WebSocket requests.
This behavior can be disabled by setting http.enabled to false.
Format Object (object) or Format Name (string) (format_spec) | |
| destinations | Array of strings <uri> [ items <uri > ] During startup connect to those WebSocket servers as a client. Each URI must use the following scheme:
It starts with a protocol which must be one of |
object (Input configuration (received by VILLASnode)) | |
| vectorize | integer Default: 1 This setting allows to send multiple samples in a single message to the destination nodes. The value of this setting determines how many samples will be combined into one packet. |
Array of Hook Object (object) or Hook Name (string) (hook_list) | |
| builtin | boolean (Builtin hook functions) Default: true By default, each node and paths has a couple of default hooks attached to them. With this setting the attachment of built-in hooks can be disabled. |
object (Output configuration (sent out by VILLASnode)) |
{- "format": "villas.human",
- "in": {
- "signals": [
- {
- "name": "tap_position",
- "type": "integer",
- "init": 0
}, - {
- "name": "voltage",
- "type": "float",
- "unit": "V",
- "init": 230
}
], - "vectorize": 1,
- "hooks": [
- "print",
- {
- "type": "limit_rate",
- "rate": 1000
}
]
}, - "vectorize": 1,
- "hooks": [
- "print",
- {
- "type": "limit_rate",
- "rate": 1000
}
], - "builtin": true,
- "out": {
- "vectorize": 0,
- "hooks": [
- "print",
- {
- "type": "limit_rate",
- "rate": 1000
}
]
}
}Example
nodes = {
ws = {
type = "websocket"
destinations = [
"ws://someserver:8080/somenode"
]
}
}
http = {
port = 8080
ssl_cert = "/etc/ssl/certs/mycert.pem"
ssl_private_key= "/etc/ssl/private/mykey.pem"
}