1

I am developing ionic mobile application with node js backend. The problem is, I want to create dynamic topics with user's username or unique id to send data from server to mobile app. what is the best way to do this task. any ideas or reference?

sameera madushan
  • 341
  • 1
  • 2
  • 11

1 Answers1

1

I found the solution for this task,

In the server created json array with name and the socket id. Then every time new user connect to the server push new user to the array with respective socket id. When emiting message go through the array, get socket id and emit to the specific user.

//sending to individual socketid
socket.broadcast.to(socketid).emit('message', 'for your eyes only');

you can find common socket commands from here: credits to https://stackoverflow.com/a/10099325

sameera madushan
  • 341
  • 1
  • 2
  • 11