mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-10-02 15:40:18 -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
|
||||
|
||||
## 1.1.4 (UNRELEASED)
|
||||
|
||||
* Added a errorHandler option to createServer.
|
||||
|
||||
## 1.1.3
|
||||
|
||||
* requires node 6
|
||||
|
@ -19,6 +19,8 @@ automatically logged in and validated against mojang's auth.
|
||||
* keepAlive : send keep alive packets : default to true
|
||||
* 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
|
||||
* 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])
|
||||
|
||||
|
@ -19,6 +19,9 @@ function createServer(options) {
|
||||
options['server-port'] != null ?
|
||||
options['server-port'] :
|
||||
25565;
|
||||
const clientErrorHandler = options.errorHandler || function(client, err) {
|
||||
client.end();
|
||||
};
|
||||
const host = options.host || '0.0.0.0';
|
||||
const kickTimeout = options.kickTimeout || 30 * 1000;
|
||||
const checkTimeoutInterval = options.checkTimeoutInterval || 4 * 1000;
|
||||
@ -47,6 +50,9 @@ function createServer(options) {
|
||||
client.once('login_start', onLogin);
|
||||
client.once('ping_start', onPing);
|
||||
client.once('legacy_server_list_ping', onLegacyPing);
|
||||
client.on('error', function(err) {
|
||||
clientErrorHandler(client, err);
|
||||
});
|
||||
client.on('end', onEnd);
|
||||
|
||||
let keepAlive = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user