0

I'd upgraded my socket.io version from 2 to 3 but the below line:

io.sockets.in(room).emit(bag.message.eventType, message)

breaks with this error:

Cannot read property 'EVENT' of undefined at Namespace.emit (/node_modules/socket.io/dist/namespace.js:170:49)

Can someone explain what syntax should go with socket.io@3 for the above code? TIA

Abhishek
  • 539
  • 5
  • 25

1 Answers1

0

As mentioned in this page https://socket.io/docs/v3/emit-cheatsheet/ you should change your code to this

io.in(room).emit(bag.message.eventType, message)

or

io.sockets.to(room).emit(bag.message.eventType, message)

mj.akbarian
  • 53
  • 2
  • 9