public static void Main() { Console.Write("\n Servers01 starting up....!!"); Console.Write("\n ==================================\n"); try { Client cl = new Client(); CommService service = new CommService(); BasicHttpBinding binding0 = new BasicHttpBinding(); Uri address0 = new Uri("http://localhost:8087/ICommService/BasicHttp"); using (service.host = new ServiceHost(typeof(CommService), address0)) { service.host.AddServiceEndpoint(typeof(ICommService), binding0, address0); service.host.Open(); Console.Write("\n CommService is ready."); Console.Write("\n Maximum BasicHttp message size = {0}", binding0.MaxReceivedMessageSize); Console.WriteLine(); Thread child = new Thread(new ThreadStart(service.ThreadProc)); //Thread ch1 = new Thread(new ThreadStart(service.ServerSender)); child.Start(); //ch1.Start(); child.Join(); //ch1.Join(); Console.Write("\n\n Press <ENTER> to terminate service.\n\n"); Console.ReadLine(); } } catch (Exception ex) { Console.Write("\n {0}\n\n", ex.Message); } }
/// <summary> /// ///////////////////////////////////////////////////////////// /// Sender thread function for sending analysis request to the server public void ClientSenderMain1(object arr) { List<string> arr1 = (List<string>)arr; CommunicationPrototype.Client client = new CommunicationPrototype.Client(); foreach (string serv in connectedservers_) { try { string url = "http://localhost:" + serv.Substring(serv.IndexOf(" ")+1) + "/ICommService/BasicHttp"; Console.Write("\n connecting to \"{0}\"\n", url); client.CreateBasicHttpChannel(url); CommunicationPrototype.Message msg = new CommunicationPrototype.Message(); string str1=""; foreach (string str in arr1) str1 += str+" "; msg.text = portno_+":"+str1; if (recurse_ == true) msg.text += ":/S"; client.channel_.PostMessage(msg); connectedservers1_.Add(serv); } catch (Exception ex) { Console.Write("{0}",ex.Message); } } if (connectedservers_.Count == 0) noservers_ = true; }
/// <summary> /// //////////////////////////////////////////////////////////////////////// /// Reciever Thread function for getting the analysis function from the server public void ClientRecieverMain1(ref List<string> a) { Console.Write("\n Communication Server Starting up"); Console.Write("\n ==================================\n"); List<string> projects = new List<string>(); CommunicationPrototype.Client cl = new CommunicationPrototype.Client(); try { CommService service = new CommService(); BasicHttpBinding binding0 = new BasicHttpBinding(); Uri address0 = new Uri("http://localhost:" + portno_ + "/ICommService/BasicHttp"); using (service.host_ = new ServiceHost(typeof(CommService), address0)) { service.host_.AddServiceEndpoint(typeof(ICommService), binding0, address0); service.host_.Open(); Message msg = new Message(); msg.text = " "; while (connectedservers1_.Count == 0) { if (noservers_) return; } Thread.Sleep(1000); int count = connectedservers1_.Count; while (count != 0) { count--; msg = service.GetMessage(); typetables_.Add(msg.text); a.Add(msg.text); } } } catch (Exception ex) { Console.Write("\n {0}\n\n", ex.Message); } }
/// <summary> /// /////////////////////////////////////////////////////////////////////// /// Sender Thread for sending the request for getting list of projects. public void ClientSenderMain(object arr) { List<string> arr1 = (List<string>)arr; CommunicationPrototype.Client client = new CommunicationPrototype.Client(); foreach (string str in arr1) { try { string url = "http://localhost:" + str + "/ICommService/BasicHttp"; Console.Write("\n connecting to \"{0}\"\n", url); client.CreateBasicHttpChannel(url); CommunicationPrototype.Message msg = new CommunicationPrototype.Message(); msg.text = "GetProjects:"+portno_+":" + patt_; client.channel_.PostMessage(msg); ((ICommunicationObject)client.channel_).Close(); connectedservers_.Add(str); } catch (Exception ex) { Console.Write("{0}", ex.Message); } Console.Write("\n\n"); } if (connectedservers_.Count == 0) noservers_ = true; }
/// <summary> /// ///////////////////////////////////////////////// /// Snder Thread function public void ServerSender(string port, string data) { Console.Write("\n BasicHttpClient Starting to Post Messages to Service"); Console.Write("\n ======================================================\n"); Client client = new Client(); try { string url = "http://localhost:"+port+"/ICommService/BasicHttp"; Console.Write("\n connecting to \"{0}\"\n", url); client.CreateBasicHttpChannel(url); Message msg = new Message(); msg.text = data; client.channel.PostMessage(msg); } catch (Exception ex) { Console.Write("\n\n {0}", ex.Message); } Console.Write("\n\n"); }