braingdx icon indicating copy to clipboard operation
braingdx copied to clipboard

Simple peer2peer networking integration 🕵️‍♀️🕵️‍♂️

Open bitbrain opened this issue 7 years ago • 0 comments

Kryonet brings already auto-discovery of network hosts. We can integrate it into the game context in order to allow us to synchronise game states and to get a simple model as follows:

public class NetworkClient {
   String getClientId();
   ClientState getClientState();
   Collection<GameObject> getGameObjects();
   int getPing();
}

And

public class Peer2PeerNetworkingContext {
   Peer2PeerState getState();
   Collection<NetworkClient> getNetworkClients();
   void addListener(NetworkingListener listener);
   void kick(String clientId);
   void disconnect();
   void connect();
}

And

public class NetworkingManager() {
   Peer2PeerNetworkingContext peer2peer();
}

This raises some concerns:

  • how to synchronise game objects over the network? What about ping, what about players leaving the game/disconnecting? Who takes responsibility in a peer-to-peer network?
  • how to deal with physics then? As explained in #70 we want to describe per client how physics look like. Maybe re-using the GameObject type for it?
  • how to deal with game creation? (waiting for other players to join?) One client in the p2p network always must be the leader

All these concerns where mostly answered in a previous 3D project of mine. Find a way to integrate it to be compatible with the GameObject model.

bitbrain avatar May 24 '17 06:05 bitbrain