I want to know if my socket is disconnected or not. In the connection every thing is fine, but I don't know how to disconnect.
Here is the server.js for the connection and the client html file.
//server.js var html = require('fs').readFileSync(__dirname + '/test.html'); var app = require('http').createServer(function(req, res) { res.end(html); }); app.listen(port); //ecoute sur le numero de port entré en paramétre console.log(' ====> Server listening on * : ' + port); var io = require("socket.io"); var io = io.listen(app); var count = 0 io.sockets.on('connection', function(socket) { socket.emit('alerte de connexion'); count ++; console.log(count + " utilisateur(s) connecté(s) à la zone de partage "); }); //client test.html <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Zone de Partage</title> </head> <body> <h1>Test de Communication effectué avec succée</h1> <script type="text/javascript" src="/socket.io/socket.io.js"></script> <script type="text/javascript"> var socket = io.connect(); socket.on('alerte de connexion', function () { alert('socket marche trés bien ! ===> voir console '); }); </script> </body> </html>