mirror of
https://github.com/karl0ss/orvibo-b25-server-kex.git
synced 2025-05-19 21:16:20 +01:00
pass in plug via envvar
This commit is contained in:
parent
57d97b0d9b
commit
ef637349b1
15
Example.js
15
Example.js
@ -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}) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user