title: Multi Client Game Server tips
body: <p>I just finished writing a simple board game for my college assignment. The game is very similar to checkers where players 2 players can move their pieces during their turns.</p>
  
  <p>My current task is making the game playable online, via a game server and game client.</p>
  
  <p>I followed some online tutorials on multiThreaded servers and I have these 2 bare bone classes:</p>
  
  <pre><code>class NetWorkServer : public QTcpServer
  {
      Q_OBJECT
  
  public:
      explicit NetWorkServer( QObject *parent = 0);
      void StartServer();
  
  private:
  
      std::vector&lt;ClientThread * &gt; _clientThreads;
  
  protected:
      void incomingConnection(int socketDescriptor);
  
  };
  
  
  
  
  class ClientThread : public QThread
  {
      Q_OBJECT
  
      QTcpSocket *socket;
      QTcpSocket * pairSocket = nullptr;
      int socketDescriptor;
      bool _isHost;
  
  public:
      explicit ClientThread(int ID, QObject *parent = 0);
      void run();
      bool isHost();
  
  signals:
  
      void error(QTcpSocket::SocketError socketerror);
  
  public slots:
      void readyRead();
      void disconnected();
  
  };
  </code></pre>
  
  <p>This works but before i continue further i need some tips. </p>
  
  <p>the way i want it to work is as following : </p>
  
  <ul>
  <li><p>A player can Host a game on the server, he will then provide all the parameters for the game creation.</p></li>
  <li><p>A player can join a hosted game, if of course there is a hosted game on the server</p></li>
  </ul>
  
  <p>And this the part where i am lost, how am i suppose to proceed from here. What would be the best way to match 2 threads of the 2  different clients that are currently in the same game? should i create another class for this (like GameSession for example)?</p>
  
  <p>Any additional reading materiel on this topic would also be very welcome. </p>