I am writing a turn-based strategy in Java with the number of players from 2 to 4. I am interested in the question of how to implement the connection between clients and the server.
At the moment everything works like this. The first server application waits for requests from other clients. The second application "client" connects to the "server", the player is listed. Something happens on the playing field, the "server" saves the state, the "client" sends a status request every second. Everything is done on Socket and ServerSocket.
The final result does not suit me, tell me how to implement or give a direction where to look, what would all be something like this:
The application "Server" is waiting for players ("Server" and is itself a player), the "client" connects, the player on the "server" makes a move, presses to complete the move. And notifies the client / clients that the clients do not request the state of the game every second.
PS Desktop application using JavaFX, runs from a regular computer, ip is reported to other players.
You all correctly described in the last paragraph. What's the question? - Nofate
(Supplement) I do not know how to make clients listen to the server. I have implemented this: the client accesses the server, the server responds to it and that's it. Those. after receiving a response from the server, the client can not be aware of the changes, if he does not contact the server again. But it is necessary that the server sends information to clients, and clients constantly wait for messages from the server. Players have a maximum of 4, I think you can keep 4 permanent connections for the duration of the game. I just took it, knowledge minimum, I can think in the wrong direction.