Documentation

Socket Extension

The Socket extension manages a socket server for devices to connect to and relay data through MudPi.

Overview

The socket extension manages a socket server for devices to connect to and relay data through. The socket listens for incoming data and detects any events that should be rebroadcast to MudPi. This is useful for getting data into MudPi through socket connections.

Socket Configuration

You can have multiple sockets started but only one per port. Here are the available configuration options:

Option Type Required Description
key String Yes Unique slug identifier for the socket
host String No Host address to connect on. Default: 127.0.0.1
port Integer No Port to use for the connection. Default: 7007
mudpi.config.json
{
  "socket": [
    {
      "key": "socket_1",
      "host": "127.0.0.1",
      "port": 7007
    }
  ]
}

Broadcasting Data

The socket listens for events in the same format as the event system. Once an event is received, it takes the event data and broadcasts it on the MudPi event bus. For example, sending a StateUpdated event is a way to trigger new data via a socket.

Note

The socket extension is a great way to integrate external devices and services with MudPi. Any device that can open a socket connection can send events into the system.