Change quit reasons to json as is now required in 1.9

This commit is contained in:
Romain Beaumont 2015-08-08 17:55:06 +02:00
parent 74e4d415fb
commit 6bad0f8461
2 changed files with 5 additions and 4 deletions

View file

@ -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) {

View file

@ -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', {