From f989bd7ca2078cd2629679f16a60d3b3d8a139f9 Mon Sep 17 00:00:00 2001 From: Jane Petrovna Date: Thu, 27 May 2021 14:33:12 -0400 Subject: [PATCH] format data --- lights.js | 10 ++++++++++ server.js | 8 ++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lights.js b/lights.js index 6295e08..871fbf4 100644 --- a/lights.js +++ b/lights.js @@ -47,6 +47,16 @@ export const functions = { subtract: (index, args, prev) => { return prev - args; } } +export const reqs = { + random: false, + constant: true, + modulo: true, + move: true, + swap: true, + add: true, + subtract: true +} + function tick_pattern() { // do the parsing stuff here log.debug("TICKING PATTERN") diff --git a/server.js b/server.js index 9b710da..524a3c8 100644 --- a/server.js +++ b/server.js @@ -1,6 +1,6 @@ import * as net from 'net'; import * as fs from 'fs'; -import { functions } from './lights.js' +import { functions, reqs } from './lights.js' import Logger, { levels } from './logger.js'; const cfg = JSON.parse(fs.readFileSync('./config.json')); @@ -16,7 +16,11 @@ export function recv(callback, errorCallback) { server.on('connection', (con) => { console.log('connection recieved: ' + con.remoteAddress + ":" + con.remotePort); - let functions_str = JSON.stringify(Object.keys(functions)); + let data = []; + for (let key in Object.keys(functions)) { + data.push({ n: key, a: reqs[key] }) + } + let functions_str = JSON.stringify(data); con.write(functions_str); log.debug(`sending ${functions_str}`); con.on('data', (data) => {