Sunday, 2 April 2017

What does the this code in socket.io mean

I am new to real-time programming using socket.io and node.js. I have seen this code from a blog site unfortunately did not post any comment or explanation about the code below:

socket.on( 'new_message', function( data ) {
  io.sockets.emit( 'new_message', {
    name: data.name, 
    address : data.address
 });
});

I have checked the socket.io documentation but there are no sufficient explanations in connection with PHP server using XAMMP.

I am using a PHP as my server-side scripting language and the code above communicates with the PHP script, but, I don't know the meaning of those codes.

after socket.on, there is a name 'new_message'. I don't know how it worked.

Also, there are JSON name: data.name , emit function,.. I don't know where did these

exist.Somebody will try to explain what's going on here?



via smzvax

No comments:

Post a Comment