major rewrite to handle schemantics
This commit is contained in:
@@ -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()
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user