I just want to confirm that any websocket(s) open on a page & connected to the server with close right away (or eventually?) when a user closed the tab. Since the console for the page is gone when closing the tab, I am not exactly sure how to test this.
The reason I want to confirm this is to figure out whether its possible to trigger a function call on the websocket close event.
Testing this on Chrome only and websockets are connect to my node server on Amazon EC2.
You can trigger the page close event in from your server using the following snippet.
var io = require('socket.io')('http');
io.on('connection', function(socket){
socket.on('disconnect', function(){
console.log('user disconnected');
});
});
But you cant trigger more that a page closing events with that function.