FIX: initSocket() without arguments

This commit is contained in:
Overtorment 2020-03-27 13:47:58 +00:00
parent aa73cd8bb3
commit 4bbd13f3c2
2 changed files with 16 additions and 0 deletions

View File

@ -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) {

View File

@ -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;
}