Properly delete the bot on disconnect

This commit is contained in:
AlexKvazos
2015-04-30 11:24:32 -05:00
parent d4476e15f7
commit cc0533377a
3 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ module.exports = function(socket) {
socket.mcbot.on('end', function() {
socket.emit('bot:disconnect');
socket.mcbot = null;
delete socket.mcbot;
});
};
+2 -1
View File
@@ -24,7 +24,8 @@ module.exports = function(socket) {
socket.mcbot.on('error', function(error) {
if (error.toString() === 'Error: write after end') return;
socket.emit('buffer:error', error);
socket.mcbot = null;
if (socket.mcbot.entity) socket.mcbot.end();
delete socket.mcbot;
});
// bind bot events
+2 -2
View File
@@ -4,7 +4,7 @@ module.exports = function(socket) {
socket.on('disconnect', function() {
if (socket.mcbot) {
socket.mcbot.end();
socket.mcbot = null;
delete socket.mcbot;
}
});
@@ -12,7 +12,7 @@ module.exports = function(socket) {
socket.on('bot:disconnect', function() {
if (socket.mcbot) {
socket.mcbot.end();
socket.mcbot = null;
delete socket.mcbot;
}
});