actually use imports, cleanup logging

This commit is contained in:
Artem Titoulenko 2021-09-07 19:09:45 -04:00
parent 792526bdaf
commit 19b5c3790d

View file

@ -1,5 +1,6 @@
const net = require('net'); const net = require('net');
const { logDataStream } = require('./util'); const { logDataStream } = require('./util');
const { FLAP } = require('./structures');
const server = net.createServer((socket) => { const server = net.createServer((socket) => {
console.log('client connected...'); console.log('client connected...');
@ -11,7 +12,6 @@ const server = net.createServer((socket) => {
socket.on('data', (data) => { socket.on('data', (data) => {
const flap = FLAP.fromBuffer(Buffer.from(data, 'hex')); const flap = FLAP.fromBuffer(Buffer.from(data, 'hex'));
console.log(logDataStream(flap.toBuffer()));
console.log('RECV', flap.toString()); console.log('RECV', flap.toString());
}); });
@ -24,10 +24,7 @@ const server = net.createServer((socket) => {
console.log('client disconnected...'); console.log('client disconnected...');
}); });
// const hello = Buffer.from(new Uint8Array([0x2a, 0x01, 0, 0x01, 0, 0x04, 0x00, 0x00, 0x00, 0x01]));
const hello = new FLAP(0x01, 0, Buffer.from([0x00, 0x00, 0x00, 0x01])); const hello = new FLAP(0x01, 0, Buffer.from([0x00, 0x00, 0x00, 0x01]));
// console.log(logDataStream(hello.toBuffer()));
socket.write(hello.toBuffer()); socket.write(hello.toBuffer());
/* 1. on connection, server sends /* 1. on connection, server sends