pass in plug via envvar

This commit is contained in:
karl0ss 2019-07-14 11:19:29 +01:00
parent 57d97b0d9b
commit ef637349b1

View File

@ -4,19 +4,24 @@ const url = require('url');
const httpPort = 3000; const httpPort = 3000;
const table =
process.env.plugArray.split(",") //["key:value","key:value"]
.map(pair => pair.split(":")); //[["key","value"],["key","value"]]
const plugArray = {};
table.forEach(([key,value]) => plugArray[key] = value);
// Create a settings object to pass PK key and map sockets to names // Create a settings object to pass PK key and map sockets to names
const settings = { const settings = {
LOG_PACKET: true, //Show incoming packet data from the socket LOG_PACKET: true, //Show incoming packet data from the socket
ORVIBO_KEY: process.env.orviboPK, // put your PK key here as plain text (See Readme) ORVIBO_KEY: process.env.orviboPK, // put your PK key here as plain text (See Readme)
plugInfo : [ plugInfo : [
// Add uid and a name so you can easily identify the connected sockets // Add uid and a name so you can easily identify the connected sockets
{ plugArray
uid :'5ccf7f22fba4',
name: "3D Printer"
},
], ],
}; };
let orvibo = new Orvibo(settings); let orvibo = new Orvibo(settings);
// When a socket first connects and initiates the handshake it will emit the connected event with the uid of the socket; // When a socket first connects and initiates the handshake it will emit the connected event with the uid of the socket;
orvibo.on('plugConnected', ({uid, name}) => { orvibo.on('plugConnected', ({uid, name}) => {