Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of Socket.io Events

Does anyone know what events are built-in in Socket.io?
For example: connection, disconnect, join etc.

like image 803
Abhishek Kaushik Avatar asked Jun 14 '14 21:06

Abhishek Kaushik


People also ask

What is Socket.IO Acknowledgement?

Acknowledgements​ In Socket.IO, this feature is named acknowledgements. You can add a callback as the last argument of the emit() , and this callback will be called once the other side acknowledges the event: io. on("connection", (socket) => { socket.

How many rooms can Socket.IO handle?

socket.io rooms are a lightweight data structure. They are simply an array of connections that are associated with that room. You can have as many as you want (within normal memory usage limits). There is no heavyweight thing that makes a room expensive in terms of resources.

How do you check if Socket.IO client is connected or not?

You can check the socket. connected property: var socket = io. connect(); console.


1 Answers

Here is all I found in the official docs:

Client-side events for socket.io object:

  • connect. Fired upon a successful connection.

  • connect_error. Fired upon a connection error.
    Parameters:
    • Object error object

  • connect_timeout. Fired upon a connection timeout.

  • reconnect. Fired upon a successful reconnection.
    Parameters:
    • Number reconnection attempt number

  • reconnect_attempt. Fired upon an attempt to reconnect.

  • reconnecting. Fired upon an attempt to reconnect.
    Parameters:
    • Number reconnection attempt number

  • reconnect_error. Fired upon a reconnection attempt error.
    Parameters:
    • Object error object

  • reconnect_failed. Fired when couldn’t reconnect within reconnectionAttempts

Client-side events for socket object:

  • connect. Fired upon connecting.
  • error. Fired upon a connection error
    Parameters:
    • Object error data
  • disconnect. Fired upon a disconnection.
  • reconnect. Fired upon a successful reconnection.
    Parameters:
    • Number reconnection attempt number
  • reconnect_attempt. Fired upon an attempt to reconnect.
  • reconnecting. Fired upon an attempt to reconnect.
    Parameters:
    • Number reconnection attempt number
  • reconnect_error. Fired upon a reconnection attempt error.
    Parameters:
    • Object error object
  • reconnect_failed. Fired when couldn’t reconnect within reconnectionAttempts

Server-side events:

  • connection / connect. Fired upon a connection.
    Parameters:
    • Socket the incoming socket.

Edit:

For the current version (1.3.4) the reconnect_attempt and reconnecting client-side events are synonyms.

like image 190
Oleg Avatar answered Oct 14 '22 05:10

Oleg