node.js - client is not receiving message from server but server is receiving from client. Using express and socket.io -


server.js file:--------------------------------------------------      var app = require('express')();                   var server = require('http').server(app);               var io = require('socket.io')(server);      server.listen(8001);      app.get('/', function (req, res) {                   res.sendfile(__dirname + '/client.html');            });      io.on('connection', function (socket) {                      socket.emit('news', 'i server');                     socket.on('my other event', function (data) {                         console.log(data);                    });                });                client.html:----------------------------------------------------      var socket = io.connect('http://localhost:8001');            socket.on('news', function (data) {             console.log(data);     });        socket.emit('my other event', 'i client'); 

now when load page http://localhost:8001, terminal shows message - 'i client'. not show message received server.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -