Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

socket.io - socket.emit, socket.on, socket.send

Based from the official site of socket.io http://socket.io/#how-to-use, I can't find any terminologies. What are the differences between socket.emit , socket.on , and socket.send ? Can't find articles which differentiate between these things. I am currently developing a real-time application.

like image 715
Orvyl Avatar asked May 17 '13 11:05

Orvyl


2 Answers

socket.emit - This method is responsible for sending messages. socket.on - This method is responsible for listening for incoming messages. socket.end - This is the first time I'm hearing such a method. I am not really sure that it exists.

like image 192
Sergey Rura Avatar answered Oct 15 '22 18:10

Sergey Rura


  • socket.emit Creates events to send data
  • socket.on listens for specific events to collect data
  • socket.send Sends events of the name message
like image 37
Jake Avatar answered Oct 15 '22 18:10

Jake