From 6bad0f846124de235479f39bcad91142ad92a7fc Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Sat, 8 Aug 2015 17:55:06 +0200 Subject: [PATCH 1/2] Change quit reasons to json as is now required in 1.9 --- src/server.js | 1 + test/test.js | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/server.js b/src/server.js index c76847f..cb8ac50 100644 --- a/src/server.js +++ b/src/server.js @@ -25,6 +25,7 @@ Server.prototype.listen = function(port, host) { var client = new Client(true); client._end = client.end; client.end = function end(endReason) { + endReason='{"text":"'+endReason+'"}'; if(client.state === states.PLAY) { client.write('kick_disconnect', {reason: endReason}); } else if(client.state === states.LOGIN) { diff --git a/test/test.js b/test/test.js index c3bc867..4eed765 100644 --- a/test/test.js +++ b/test/test.js @@ -439,7 +439,7 @@ describe("client", function() { }); var gotKicked = false; client.on([states.LOGIN, 0x00], function(packet) { - assert.strictEqual(packet.reason, '"Failed to verify username!"'); + assert.strictEqual(packet.reason, '{"text":"Failed to verify username!"}'); gotKicked = true; }); client.on('end', function() { @@ -498,7 +498,7 @@ describe("mc-server", function() { var count = 2; server.on('connection', function(client) { client.on('end', function(reason) { - assert.strictEqual(reason, "LoginTimeout"); + assert.strictEqual(reason, '{"text":"LoginTimeout"}'); server.close(); }); }); @@ -527,7 +527,7 @@ describe("mc-server", function() { var count = 2; server.on('connection', function(client) { client.on('end', function(reason) { - assert.strictEqual(reason, "KeepAliveTimeout"); + assert.strictEqual(reason, '{"text":"KeepAliveTimeout"}'); server.close(); }); }); @@ -682,7 +682,7 @@ describe("mc-server", function() { var count = 2; server.on('login', function(client) { client.on('end', function(reason) { - assert.strictEqual(reason, 'ServerShutdown'); + assert.strictEqual(reason, '{"text":"ServerShutdown"}'); resolve(); }); client.write('login', { From 6bacdf33ccfc0584583a3bbc12dcb12f04edd626 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Mon, 14 Sep 2015 22:48:00 +0200 Subject: [PATCH 2/2] check if the reason contains the quoted reason instead of strict equality : make the tests work with the same code in 1.8 and 1.9 --- test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.js b/test/test.js index 4eed765..e2bfa04 100644 --- a/test/test.js +++ b/test/test.js @@ -439,7 +439,7 @@ describe("client", function() { }); var gotKicked = false; client.on([states.LOGIN, 0x00], function(packet) { - assert.strictEqual(packet.reason, '{"text":"Failed to verify username!"}'); + assert.ok(packet.reason.indexOf('"Failed to verify username!"')!=-1); gotKicked = true; }); client.on('end', function() {