gently close the connection before leaving the page

This commit is contained in:
Jan Eggers
2017-10-24 13:15:35 +02:00
parent e80d21e852
commit 0e0fcabc04
@@ -13,4 +13,8 @@ client.on('connect', () => {
client.on('message', (topic, message) => { client.on('message', (topic, message) => {
// message is Buffer // message is Buffer
console.log(message.toString()); console.log(message.toString());
}) });
window.onbeforeunload = () => {
client.end();
};