mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-28 05:35:56 -04:00
Merge pull request #539 from FuturisticCake/master
Emit errors instead of throwing.
This commit is contained in:
commit
834c8785af
@ -194,7 +194,7 @@ class Client extends EventEmitter
|
|||||||
|
|
||||||
setEncryption(sharedSecret) {
|
setEncryption(sharedSecret) {
|
||||||
if (this.cipher != null)
|
if (this.cipher != null)
|
||||||
throw new Error("Set encryption twice !");
|
this.emit('error', new Error('Set encryption twice!'));
|
||||||
this.cipher = crypto.createCipheriv('aes-128-cfb8', sharedSecret, sharedSecret);
|
this.cipher = crypto.createCipheriv('aes-128-cfb8', sharedSecret, sharedSecret);
|
||||||
this.cipher.on('error', (err) => this.emit('error', err));
|
this.cipher.on('error', (err) => this.emit('error', err));
|
||||||
this.framer.unpipe(this.socket);
|
this.framer.unpipe(this.socket);
|
||||||
|
@ -11,7 +11,7 @@ module.exports = function(client, options) {
|
|||||||
debug('pinging',options.host);
|
debug('pinging',options.host);
|
||||||
// TODO: use 0xfe ping instead for better compatibility/performance? https://github.com/deathcap/node-minecraft-ping
|
// TODO: use 0xfe ping instead for better compatibility/performance? https://github.com/deathcap/node-minecraft-ping
|
||||||
ping(options, function(err, response) {
|
ping(options, function(err, response) {
|
||||||
if (err) throw err; // hmm
|
client.emit('error',err);
|
||||||
debug('ping response',response);
|
debug('ping response',response);
|
||||||
// TODO: could also use ping pre-connect to save description, type, max players, etc.
|
// TODO: could also use ping pre-connect to save description, type, max players, etc.
|
||||||
const motd = response.description;
|
const motd = response.description;
|
||||||
@ -30,7 +30,7 @@ module.exports = function(client, options) {
|
|||||||
.sort(function (a, b) { return b.version - a.version })
|
.sort(function (a, b) { return b.version - a.version })
|
||||||
.concat(minecraft_data.postNettyVersionsByProtocolVersion["pc"][protocolVersion]||[])
|
.concat(minecraft_data.postNettyVersionsByProtocolVersion["pc"][protocolVersion]||[])
|
||||||
if (versions.length === 0) {
|
if (versions.length === 0) {
|
||||||
throw new Error(`unsupported/unknown protocol version: ${protocolVersion}, update minecraft-data`);
|
client.emit('error', new Error(`unsupported/unknown protocol version: ${protocolVersion}, update minecraft-data`));
|
||||||
}
|
}
|
||||||
const minecraftVersion = versions[0].minecraftVersion;
|
const minecraftVersion = versions[0].minecraftVersion;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user