private void conn() { string configtext = System.IO.File.ReadAllText(@"config.json"); Console.WriteLine("Content of the file: {0}", configtext); JObject config = JObject.Parse(configtext); string languageoption = (string)config["Language"]; ConnectionClass.config = new configFile((string)config["IpAdress"], (int)config["port"], languageoption); if (languageoption != "Romanian") { string configlanguagepath = @"languages/" + languageoption + ".json"; string jsonlanguageconfig = System.IO.File.ReadAllText(configlanguagepath); languageSupporter supporter = new languageSupporter(jsonlanguageconfig); ConnectionClass.languagesupporter = supporter; } ClientTCP client = new ClientTCP((string)config["IpAdress"], (int)config["port"], 10000); ConnectionClass.ClientTCP = client; Console.WriteLine(config["IpAdress"]); Thread th = new Thread(new ParameterizedThreadStart(ReapetUntilConnected)); th.Start(client); client.OnResponse += Client_OnResponse; client.OnConnectionLost += Client_OnConnectionLost; }
private void ReapetUntilConnected(object client) { ClientTCP tcpclient = (ClientTCP)client; while (true) { Task.Delay(100); int response = tcpclient.DoConnection(); if (response == ClientTCP.CONECTIONSUCCESS) { this.SetConnectionState("Connected"); //ConnectionClass.ClientTCP = tcpclient; setcookie(); break; } } }
private void conn() { string configtext = System.IO.File.ReadAllText(@"config.json"); Console.WriteLine("Content of the file: {0}", configtext); JObject config = JObject.Parse(configtext); ClientTCP client = new ClientTCP((string)config["IpAdress"], (int)config["port"], 10000); Console.WriteLine(config["IpAdress"]); Thread th = new Thread(new ParameterizedThreadStart(ReapetUntilConnected)); th.Start(client); client.OnResponse += Client_OnResponse; client.OnConnectionLost += Client_OnConnectionLost; }