I tried to learn java by myself and decide to design a very simple server that will handle a few clients. There are server and client classes. I tried to look for reference online but couldnt find any.
Brief description, server runs, and listen for incoming connections from clients, I can manage to get the server to send the questions to client and client can send back the answer. But, I can't manage to synchronise them, in the sense, I failed to make the server waits fom at least 2 clients are connected to start the game, and I want those clients are in the same game, and they compete each other to get the answer right and tracking the time for the client to answer the question. Additionally, if the game is still running, if there is any new connection from client, instead of making them wait for the game to end, it'll be good if the can observe the current game, i.e server sends questions to them and show them the answer of other clients, but they're not allowed to play.
Any help or idea of how to do that? I attached codes that I've written so far so you can look at it. Thank you very much