To setup thebit you'll need to run npm install in the directory you clone the repo to. Afterwards you'll need to create a copy of the config files. Based on what controllers you use this may include a .env with environment variables with details for ATEM or OBS connections as seen below.
ATEM_IP_ADDRESS=192.168.0.XXXj
OBS_WS_ADDRESS=192.168.0.XXX
OBS_WS_PASSWORD=<passwordGeneratedByOBS>You can copy the .env.example file to .env and fill in your details to get started.
cp ./.env.example ./.envAfterwards you'll need to do update thebit.config.js with your settings.
Listeners are defined in the config.js file under the listeners key. Inside you can define a listener type (currently Socket.IO or a WebSocket). Additionally you define an array of rules for the listener to apply to it's defined controller. Rules contain a function key that should be a javascript function that returns a JS object that implements theListenerAction interface.
For example, for an OBS Controller, if you were listening for the message donation:show from a Socket.IO server this would run the shrink action on scene player1 with a magnitude of 0.5.
rules: [
{
on: "donation:show",
function: (args) => {
return {action: "shrink", path: "player1", magnitude: 0.5}
}
}
]To address instances where you could potentially recieve duplicates of a message, listeners implement a history of 100 unique id's. Unique ID's must be provided by the server we are listening to and you can identify what value in the event can be used as such by returning a "uid" key in your script as part of the returned ListenerAction.
For example
rules: [
{
on: "donation:show",
function: (event) => {
return {
action: "shrink",
path: "player1",
magnitude: 0.4,
uid: event.unique_id_from_sender
}
}
}
]When developing you can use npm run dev to run with nodemon to automatically
reload as you make changes to the files.
For testing WSListeners you can use node scripts/wsserver.js, just ensure your .env has a WS_ADDRESS set in it like so
WS_ADDRESS=ws://localhost:8080You can then send test messages via like so
./scripts/test.sh send amount 10.00 donationid abc123 event donation:show
The test.sh script has a few odd commands in it but the most important is send which lets you send a simple JSON formatted message over the server created via wsserver.js. This requires having websocat and js available on your machine.
To run this in a production capacity you'll need to run it with npm run start.