mirror of
https://github.com/Threnklyn/MinecraftChat.git
synced 2026-05-18 20:33:28 +02:00
Properly delete the bot on disconnect
This commit is contained in:
@@ -2,7 +2,7 @@ module.exports = function(socket) {
|
||||
|
||||
socket.mcbot.on('end', function() {
|
||||
socket.emit('bot:disconnect');
|
||||
socket.mcbot = null;
|
||||
delete socket.mcbot;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user