The socket
extension manages a socket for devices to connect to and relay data through. The socket listens for incoming data and tries to detect any events that should be rebroadcast to MudPi. The socket extension is really useful to get data into MudPi throgh sockets.
You can have multiple sockets started but only one per port. Here are some available configuration options.
Option | Type | Required | Description |
key | [String] | Yes | Unique slug id for the socket |
host | [String] | No | Host address to connect on. Default: 127.0.0.1 . |
port | [Integer] | No | Port to use for connection. Default: 7007 . |
Here is a config of a complete socket.
"socket": [{
"key": "socket_1",
"host": "127.0.0.1",
"port": 7007
}]
The socket is setup to listen for events in the same format as the event system. Once an event is received it will take the event data and broadcast it on the MudPi event bus. For example sending a StateUpdated
event could be a way to trigger new data via a socket.