major rewrite to handle schemantics

This commit is contained in:
heri16
2020-08-06 11:48:36 +08:00
parent 58c4cb9e7d
commit 42ab8c2aee
4 changed files with 1234 additions and 340 deletions

View File

@@ -2,7 +2,7 @@
const libzt = require('./libzt')
// libzt.example()
// libzt.example("8056c2e21c000001", "29.49.7.203", 4444)
libzt.start(".zerotier", 9994)
@@ -10,15 +10,16 @@ libzt.join("8056c2e21c000001")
// Usage: `nc -lv 4444`
let client = libzt.createConnection({ port: 4444, host: '29.49.7.203' }, () => {
// 'connect' listener.
console.log('connected to server!');
// client.write('world!\r\n');
});
client.write("Name?\n", 'utf8');
client.on('ready', () => {
client.write("Name?\n", 'utf8');
});
client.on('data', (data) => {
console.log(data.toString());
client.end();
console.log(data.toString('utf8').trimEnd());
if (data.toString('utf8').includes("exit")) { client.end(); }
});
client.on('end', () => {
console.log('disconnected from server');
libzt.stop()
});