public void RunClient(object ipAddress)
        {
            client = new TcpClient(ipAddress.ToString(), 6969);

            while (true)
            {
                JObject received = TcpReadWrite.Read(client);
                string  command  = (string)received["command"];

                switch (command)
                {
                case "id":
                    form.Invoke(new Action(() => form.GetId(TcpProtocol.ReadId(received))));
                    break;

                case "questionScores":
                    form.Invoke(new Action(() => form.HandleQuestionsScores(TcpProtocol.QuestionAndScoreParse(received))));
                    break;

                case "endScores":
                    form.Invoke(new Action(() => form.HandleEndGame(TcpProtocol.EndScoresParse(received))));
                    client.GetStream().Close();
                    client.Close();
                    return;
                }
            }
        }
 public JObject Read()
 {
     try
     {
         return(TcpReadWrite.Read(client));
     }
     catch (Exception)
     {
         Console.WriteLine("Exception");
         return(null);
     }
 }
 public void Write(JObject message)
 {
     TcpReadWrite.Write(client, message);
 }
 public void SendTime(int time)
 {
     TcpReadWrite.Write(client, TcpProtocol.TimeSend(time));
 }