Beispiel #1
0
        private void ClientComm(object client)
        {
            using (TcpClient tcpClient = (TcpClient)client)
            {
                //Neuen NetworkStream anlegen
                using (NetworkStream clientStream = tcpClient.GetStream())
                {
                    while (true)
                    {
                        try
                        {
                            if (tcpClient.Available == 0)
                            {
                                break;
                            }

                            //Neues URL Objekt
                            Url theNew = new Url();

                            //Einlesen
                            Request neuerReader = new Request(clientStream);
                            theNew = (Url)neuerReader.getURL();
                            string pluginName = theNew.getPluginName();
                            //string[] splitString = theNew.getSplitUrl();
                            Dictionary <string, string> splitString = theNew.getSplitUrl();

                            //Nachricht an Client

                            Response neuerWriter = new Response(clientStream, theNew);


                            //An Plugin Manager weiterreichen
                            if (!String.IsNullOrEmpty(pluginName))
                            {
                                plugin.HandleRequest(theNew, clientStream);
                            }

                            //Console.WriteLine("PluginName: {0}", pluginName);

                            Console.WriteLine("No. {0} disconnected *~ ", Threadcount);
                            Console.WriteLine("____________________________");
                            return;
                        }

                        catch (Exception ex)
                        {
                            Console.WriteLine("Magic failed... :(.... " + ex.ToString());
                            return;
                        }
                    }
                }
            }
        }
Beispiel #2
0
        private void ClientComm(object client)
        {
            using (TcpClient tcpClient = (TcpClient)client)
            {
                //Neuen NetworkStream anlegen
                using (NetworkStream clientStream = tcpClient.GetStream())
                {
                    while (true)
                    {
                        try
                        {
                            if (tcpClient.Available == 0) break;

                            //Neues URL Objekt
                            Url theNew = new Url();

                            //Einlesen
                            Request neuerReader = new Request(clientStream);
                            theNew = (Url)neuerReader.getURL();
                            string pluginName = theNew.getPluginName();
                            string[] splitString = theNew.getSplitUrl();

                            //Nachricht an Client
                            if(splitString.Length<=1)
                            {
                                Response neuerWriter = new Response(clientStream, theNew);
                            }

                            //An Plugin Manager weiterreichen
                            if (!String.IsNullOrEmpty(pluginName))
                            {
                                plugin.HandleRequest(theNew, clientStream);
                            }

                            //Console.WriteLine("PluginName: {0}", pluginName);

                            Console.WriteLine("No. {0} disconnected *~ ", Threadcount);
                            Console.WriteLine("____________________________");
                            return;
                        }

                        catch(Exception ex)
                        {
                            Console.WriteLine("Magic failed... :(.... " + ex.ToString());
                            return;
                        }
                    }
                }
            }
        }