javascript - Socket.io client not receiving message event -


my project's skeleton of express-generator used workaround:here

server:

io.on('connection', function(socket){ socket.on('message', function(msg){   io.emit('message', msg); }); }); 

client:(src socket included)

var  socket = io.connect('//localhost:5000');   function op(){   socket.emit('message', $('input[name=yolo]:checked', '#myform').val());  };   socket.on('message', function(msg){      console.log("oo");      $("input[value=msg]").attr('disabled',true);      alert($("input[value=msg]").val());  }); 

form

form(action='' id="myform") ///form inputs input(type="submit" value="book" onclick="op()")  
  1. connection made on both sides verified.

  2. message received server isn't emitting client side socket.on('message'... trigger.

  3. tested every step last socket.on('message'.. not triggering.

change

io.on('connection', function(socket){ socket.on('message', function(msg){   io.emit('message', msg); }); }); 

to

io.on('connection', function(socket){ socket.on('message', function(msg){   socket.emit('message', msg); }); }); 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -