Monday, 15 July 2019

Difficulty with regularly emitting from a socket.io server on an interval

I'm trying to create a socket.io server using nestjs. I want to declare a count and loop incrementally to send count + 1. I want it to loop so that the client just receives the next payload without requesting it. In other words, the client connects, listens to 'tick', then console logs out 0, 1, 2, 3, etc. Each number is pushed by the server to the client.What is the best way to go about this? I'm thinking of setInterval and async generators because most of my code (game of life simulator) is async. The count is just a simple test to get the looping going for the real code. I'm struggling getting the simple test to work. Any tips or links about using loops with websockets?

Submitted July 15, 2019 at 05:25PM by BithTree

No comments:

Post a Comment