mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-10-01 15:10:24 -04:00
Merge pull request #463 from roblabla/feature-addErrorHandler
Add errorHandler option
This commit is contained in:
commit
5126b96954
@ -1,5 +1,9 @@
|
|||||||
# History
|
# History
|
||||||
|
|
||||||
|
## 1.1.4 (UNRELEASED)
|
||||||
|
|
||||||
|
* Added a errorHandler option to createServer.
|
||||||
|
|
||||||
## 1.1.3
|
## 1.1.3
|
||||||
|
|
||||||
* requires node 6
|
* requires node 6
|
||||||
|
@ -19,6 +19,8 @@ automatically logged in and validated against mojang's auth.
|
|||||||
* keepAlive : send keep alive packets : default to true
|
* keepAlive : send keep alive packets : default to true
|
||||||
* version : 1.8 or 1.9 : default to 1.8
|
* version : 1.8 or 1.9 : default to 1.8
|
||||||
* customPackets (optional) : an object index by version/state/direction/name, see client_custom_packet for an example
|
* customPackets (optional) : an object index by version/state/direction/name, see client_custom_packet for an example
|
||||||
|
* errorHandler : A way to override the default error handler for client errors. A function that takes a Client and an error.
|
||||||
|
The default kicks the client.
|
||||||
|
|
||||||
## mc.Server(version,[customPackets])
|
## mc.Server(version,[customPackets])
|
||||||
|
|
||||||
|
@ -19,6 +19,9 @@ function createServer(options) {
|
|||||||
options['server-port'] != null ?
|
options['server-port'] != null ?
|
||||||
options['server-port'] :
|
options['server-port'] :
|
||||||
25565;
|
25565;
|
||||||
|
const clientErrorHandler = options.errorHandler || function(client, err) {
|
||||||
|
client.end();
|
||||||
|
};
|
||||||
const host = options.host || '0.0.0.0';
|
const host = options.host || '0.0.0.0';
|
||||||
const kickTimeout = options.kickTimeout || 30 * 1000;
|
const kickTimeout = options.kickTimeout || 30 * 1000;
|
||||||
const checkTimeoutInterval = options.checkTimeoutInterval || 4 * 1000;
|
const checkTimeoutInterval = options.checkTimeoutInterval || 4 * 1000;
|
||||||
@ -47,6 +50,9 @@ function createServer(options) {
|
|||||||
client.once('login_start', onLogin);
|
client.once('login_start', onLogin);
|
||||||
client.once('ping_start', onPing);
|
client.once('ping_start', onPing);
|
||||||
client.once('legacy_server_list_ping', onLegacyPing);
|
client.once('legacy_server_list_ping', onLegacyPing);
|
||||||
|
client.on('error', function(err) {
|
||||||
|
clientErrorHandler(client, err);
|
||||||
|
});
|
||||||
client.on('end', onEnd);
|
client.on('end', onEnd);
|
||||||
|
|
||||||
let keepAlive = false;
|
let keepAlive = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user