Additional async rewrite

This commit is contained in:
mmorrison 2019-01-12 04:43:36 -06:00
parent efe12a00aa
commit 29ce0b82d0
24 changed files with 654 additions and 470 deletions

View file

@ -2,12 +2,6 @@ const gbxremote = require('gbxremote'),
Core = require('./core');
class Nadeo extends Core {
constructor() {
super();
this.options.port = 2350;
this.options.port_query = 5000;
}
async run(state) {
await this.withClient(async client => {
await this.methodCall(client, 'Authenticate', this.options.login, this.options.password);
@ -57,8 +51,8 @@ class Nadeo extends Core {
}
async withClient(fn) {
const socket = gbxremote.createClient(this.options.port_query, this.options.host);
const cancelAsyncLeak = this.addAsyncLeak(() => socket.terminate());
const socket = gbxremote.createClient(this.options.port, this.options.host);
const cancelAsyncLeak = this.addCleanup(() => socket.terminate());
try {
await this.timedPromise(
new Promise((resolve,reject) => {