Reputation: 536
I am using NODEJS+Socket.IO to control a raspberry pi pin. I have all the features working but I need to initiate a pin to be high if a client (user on the browser) closes the connection i.e closes their tab? Here is what I have tried
io.sockets.on('disconnect', function(){
console.log("connection lost");
});
Any Suggestions?
Upvotes: 3
Views: 1024
Reputation: 44107
Use socket.on("disconnect")
:
io.on("connection", socket => {
socket.on("disconnect", () => console.log("Connection Lost"));
});
Upvotes: 8