j'essaie de suivre La Documentation.
la connexion est faite sans aucun problème Pièce jointe 225125
mais les messages écrits par l'utilisateur ne sont pas detectés, ni par le cmd ni par jQuery.
index.html :
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!doctype html>
<html>
  <head>
    <title>Socket.IO chat</title>
    <style>
      * { margin: 0; padding: 0; box-sizing: border-box; }
      body { font: 13px Helvetica, Arial; }
      form { background: #000; padding: 3px; position: fixed; bottom: 0; width: 100%; }
      form input { border: 0; padding: 10px; width: 90%; margin-right: .5%; }
      form button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; }
      #messages { list-style-type: none; margin: 0; padding: 0; }
      #messages li { padding: 5px 10px; }
      #messages li:nth-child(odd) { background: #eee; }
    </style>
 
  </head>
  <body>
    <ul id="messages"></ul>
    <form action="" id="form">
      <input id="m" name="messg" autocomplete="off" />
      <input type="button" id="submit" value="Send"/>
	</form><script src="../global_jQuery/jquery-3.1.1.js"></script>
	<script type="text/javascript" src="node_modules/socket.io-client/socket.io.js"></script>
	<script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
 
 
    <script>
          var socket = io.connect('http://localhost:3000/IOSocket');
                $('#submit').click(function(e){
                        var _message=$("#m").val();
                        socket.emit('chat',_message);
                        $('#m').val('');
                        //return false;
          });
      socket.on('chat', function(msg){
                $('#messages').append($('<li>').text(msg));
                alert("message");
      });
         
         
    </script>
 
 
  </body>
</html>

index.js
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 
/*************************************************/
var http = require('http');
var fs = require('fs');
 
// Chargement du fichier index.html affiché au client
var server = http.createServer(function(req, res) {
    fs.readFile('./index.html', 'utf-8', function(error, content) {
        res.writeHead(200, {"Content-Type": "text/html"});
        res.end(content);
    });
});
// Chargement de socket.io
var io = require('socket.io').listen(server);
/*********************************************/
 
io.on('connection', function(socket){
	console.log('un utilisateur vient de se connecté');
	socket.on('chat', function(msg){
		io.emit('chat:',{data:'Salut'});
		console.log("samawiii :"+msg);
	  });
});
 
 
server.listen(3000, function(){
  console.log('listening on *:3000');
});