format data

This commit is contained in:
jane 2021-05-27 14:33:12 -04:00
parent 091590f9ca
commit f989bd7ca2
2 changed files with 16 additions and 2 deletions

View file

@ -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")

View file

@ -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) => {