From 4ab4d924d9919ec4f5bfac81023e365b72fad8b7 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Fri, 23 Mar 2018 07:55:47 +0100 Subject: Handjeswapper ~ --- protocol.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'protocol.js') diff --git a/protocol.js b/protocol.js index a1be542..22baf03 100644 --- a/protocol.js +++ b/protocol.js @@ -68,6 +68,7 @@ class Connection { constructor(conn, msgCb) { this.conn = conn; lineReader(conn, (line) => { + console.log("Received line '" + line + "'"); let obj; try { obj = JSON.parse(line); @@ -75,7 +76,9 @@ class Connection { if (module.exports.debug) console.log("Invalid JSON received: " + line); return; } - if (obj.res || obj.err) { + if (obj.method) { + msgCb(new Message(obj.method, ...obj.args)); + } else { const msg = new Message(obj.id, obj.res, obj.err); if (this.replyHandlers[msg.id]) { this.replyHandlers[msg.id](msg); @@ -83,8 +86,6 @@ class Connection { } else { if (module.exports.debug) console.log("Reply for unexpected message id " + msg.id); } - } else { - msgCb(new Message(obj.method, ...obj.args)); } }); @@ -94,7 +95,7 @@ class Connection { this.pingInterval = setInterval(async () => { const msg = await this.send(new Message("ping")); if (module.exports.debug) console.log("Ping reply: " + util.inspect(msg)); - }, 30000); + }, 600000); } send(msg) { -- cgit v1.2.3-54-g00ecf