Replaced throw for "Set encryption twice!" error with emit.

This commit is contained in:
Ethan Davis 2018-01-16 18:24:48 -08:00
parent 01f8342f9e
commit c4fbd81674

View file

@ -194,7 +194,7 @@ class Client extends EventEmitter
setEncryption(sharedSecret) {
if (this.cipher != null)
throw new Error("Set encryption twice !");
this.emit('error','Set encryption twice!');
this.cipher = crypto.createCipheriv('aes-128-cfb8', sharedSecret, sharedSecret);
this.cipher.on('error', (err) => this.emit('error', err));
this.framer.unpipe(this.socket);