add command discovery
This commit is contained in:
parent
6df19467fb
commit
89085b94b1
2 changed files with 7 additions and 1 deletions
|
@ -42,9 +42,13 @@ let functions = {
|
|||
constant: (index, args, prev) => { return args; },
|
||||
modulo: (index, args, prev) => { return prev % args; },
|
||||
move: (index, args, prev) => { targets[args] = prev; return prev; },
|
||||
swap: (index, args, prev) => { let temp = targets[args]; targets[args] = prev; return temp; }
|
||||
swap: (index, args, prev) => { let temp = targets[args]; targets[args] = prev; return temp; },
|
||||
add: (index, args, prev) => { return prev + args; },
|
||||
subtract: (index, args, prev) => { return prev - args; }
|
||||
}
|
||||
|
||||
export functions;
|
||||
|
||||
function tick_pattern() {
|
||||
// do the parsing stuff here
|
||||
log.debug("TICKING PATTERN")
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import * as net from 'net';
|
||||
import { functions } from './lights.js'
|
||||
|
||||
const hostname = '0.0.0.0';
|
||||
const port = 29999;
|
||||
|
@ -9,6 +10,7 @@ export function recv(callback, errorCallback) {
|
|||
server.on('connection', (con) => {
|
||||
console.log('connection recieved: ' +
|
||||
con.remoteAddress + ":" + con.remotePort);
|
||||
con.write(JSON.stringify(Object.keys(functions)));
|
||||
con.on('data', (data) => {
|
||||
callback(data);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue