Answer the question
In order to leave comments, you need to log in
How to organize a quiz with timers on a websocket on a server?
i want to write a nodejs quiz. on the client, users connect via websocket.io to the server. the quiz works for me like this, a round of 10 questions is created in which two users fall. a minute is given for each question, after a minute it changes to another, or changes as one of the users answers the question. after 10 questions, points are counted and the winner is declared.
I do not understand how to answer my questions:
1) how to create a time counter on the server? I understand that there is a setinterval, but this counter will be for the entire server, and it can have 20 quizzes with 40 players, for example. I don't understand, do I need to create 20 counters? or is 1 counter looking to see if the question is over in every 20 quizzes? and how to write it technically,exactly the code? I can't understand
2) if I store the answers to the questions in the server's memory, and only after the end of the quiz write the data to the database, then how can I store them? in json object? or do I need external storage and why?
3) what does the server physically look like, can I just keep all the quizzes in one thread? or you need to do something complicated, cluster / workers, am I missing some aspect?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question