I am trying to implement a 2 player game. Where the 2 clients communicate with the server to play the game and server decides which player has won the game. I am using distributed approach using TCP connection.

As part of my implementation I will have to see that even though one client is right beside the server and other client in located miles away, both the client should get the response from the server at almost same time. In one part of my game the server displays a prompt box to both the clients and the client who clicks the box will be the winner. For the server to decide this, I want to use cristains algorithm for clock synchronization.

My problem is I have an idea what to do but finding it difficult to write the code.

1

There are 1 best solutions below

0
On

This might help, it will allow players to subscribe to a topic and post/get messages to and from that topic, I've used this for a 2 player game and it worked fine http://docs.oracle.com/javaee/7/tutorial/doc/websocket.htm