From ef637349b144089b911d214cb1ff5424f69a4f6b Mon Sep 17 00:00:00 2001 From: karl0ss Date: Sun, 14 Jul 2019 11:19:29 +0100 Subject: [PATCH] pass in plug via envvar --- Example.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Example.js b/Example.js index bf67162..89319e2 100644 --- a/Example.js +++ b/Example.js @@ -4,19 +4,24 @@ const url = require('url'); 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 const settings = { 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) plugInfo : [ // Add uid and a name so you can easily identify the connected sockets - { - uid :'5ccf7f22fba4', - name: "3D Printer" - }, + plugArray ], }; - + 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; orvibo.on('plugConnected', ({uid, name}) => {