From 4bbd13f3c2b9ae683ee8ec064d770be1f76b23a7 Mon Sep 17 00:00:00 2001 From: Overtorment Date: Fri, 27 Mar 2020 13:47:58 +0000 Subject: [PATCH] FIX: initSocket() without arguments --- lib/TlsSocketWrapper.js | 9 +++++++++ lib/client.js | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/lib/TlsSocketWrapper.js b/lib/TlsSocketWrapper.js index e8182f1..0175029 100644 --- a/lib/TlsSocketWrapper.js +++ b/lib/TlsSocketWrapper.js @@ -88,6 +88,9 @@ class TlsSocketWrapper { this._socket.on('timeout', () => { this._passOnEvent('timeout'); }); + this._socket.on('onerror', data => { + this._passOnEvent('onerror', data); + }); this._socket.on('error', data => { this._passOnEvent('error', data); }); @@ -97,6 +100,12 @@ class TlsSocketWrapper { this._socket.on('connect', data => { this._passOnEvent('connect', data); }); + this._socket.on('secureConnect', data => { + this._passOnEvent('secureConnect', data); + }); + this._socket.on('connection', data => { + this._passOnEvent('connection', data); + }); } _passOnEvent(event, data) { diff --git a/lib/client.js b/lib/client.js index cb00397..79d1310 100644 --- a/lib/client.js +++ b/lib/client.js @@ -27,10 +27,14 @@ class Client { this.mp = new util.MessageParser((body, n) => { this.onMessage(body, n); }); + this._protocol = protocol; // saving defaults + this._options = options; this.initSocket(protocol, options); } initSocket(protocol, options) { + protocol = protocol || this._protocol; + options = options || this._options; switch (protocol) { case 'tcp': this.conn = new net.Socket(); @@ -75,6 +79,9 @@ class Client { this.conn.on('error', e => { this.onError(e); }); + this.conn.on('onerror', e => { + this.onError(e); + }); this.status = 0; }