Beispiel #1
0
        public bool WaitForDad()
        {
            bool recievedDad = false;

            while (true) // default loop for waiting
            {
                byte[] bytesToRead = new byte[client.ReceiveBufferSize];
                int    bytesRead   = nwStream.Read(bytesToRead, 0, client.ReceiveBufferSize);
                string emptyCheck  = null;
                try
                {
                    string raw = Encoding.ASCII.GetString(bytesToRead, 0, bytesRead);
                    emptyCheck = cry.CustomDecrypt(raw);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }
                if (emptyCheck != null) // Data present
                {
                    // Correct data sent is in this format
                    // function_enum:arguments_if-needed:string_data_of_something
                    // custom handling AKA plugin handling
                    // custom:byte_data:class_name:method_name(aka function name)
                    // Initialize and process custom request with CustomHandler class
                    string[] data = emptyCheck.Split(':');
                    if (data[0].ToLower().Contains("custom"))
                    {
                        CustomHandler cst = new CustomHandler();
                        cst.ProccessRequest(emptyCheck);
                        // TODO: Debug the process, figure out if we can dispose or not
                    }
                }
                else
                {
                    Thread.Sleep(800); // Wait then loop back to checking for shit
                }
                Thread.Sleep(800);     // Wait then loop back to checking for shit
                Console.WriteLine("Waiting for work assignment...");
            }

            return(recievedDad);
        }