Categories
Mastering Development

Multiple socket.event inside one socket.on

I am trying an application that emits multiple times when it is called once. For example:

`

io.on('connection', socket => {
   socket.on('compute-library', message => {
   while (true) {
     socket.emit('status', 1)
   };
  });
});

However, when I am running my application, I only get a single emit element. If I add a termination condition for the loop. In the last emit I get the whole list of emits following it. How can we resolve this issue? Does there needs to be a single emit inside socket.on or we can have multiple. `

Leave a Reply

Your email address will not be published. Required fields are marked *