diff options
Diffstat (limited to 'protocol.js')
-rw-r--r-- | protocol.js | 9 |
1 files changed, 5 insertions, 4 deletions
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) { |