mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-31 03:02:39 +08:00
gently close the connection before leaving the page
This commit is contained in:
@@ -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();
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user