All disabled Emit commands in Socket.IO

Tram Ho

Purpose

Easy to read and use when not remembering emit commands in Socket IO

List of Emit commands in Socket IO

I will write a make a Socket IO connection and put all emit commands inside to make it easy to visualize.

Note

  1. socket.to(socket.id).emit() will fail. This error is common when you want to send private messages. If used like this will understand socket.id is a room, not a socket.

    I will use io.to ( ${socketId} ) .emit (‘hey’, ‘I just met you’); to send a private message.

  2. The following event names are not allowed:
    • error
    • connect
    • disconnect
    • disconnecting
    • newListener
    • removeListener
    • ping
    • pong
  3. After server disconnected or restart, the conection will be released. That means sending private messages via socket.id will have to follow the new socket.id the connection created.

Epilogue

These are all Emit commands in Socket IO that everyone who used socketio can save on the note on the device to be able to use. Good luck to everyone 😀👍 .

Reference link: https://socket.io/docs/emit-cheatsheet/

Share the news now

Source : Viblo