Send events with SokcetIO and NodeJS

0

I have a / index path in which I have the following script

socket.on('m',function(){ console.log('hola mundo') })

on the route / two I have

$('#btn-send').click(function(){
      socket.emit('hola')
}

both have the connect, and they connect well in independent cases, what I need is that when you click on the sen button in the / two path, 'hello' is issued to the server and the same emit 'm' that in the path / index write hello world in the console, the server is like this, save code to copy:

io.on('connection',socket => {
   socket.on('hola',()=>{
        socket.emit('m')
   })    
}

What happens is that when I press the send button, the event 'm' never reaches the / index path and does not perform the operation

    
asked by Travv 21.11.2017 в 22:12
source

0 answers