示例#1
0
        public static bool FindElementsFromElement(string body, string[] args, HttpListenerResponse response)
        {
            string elementId = args [0].Replace("\"", "");

            GameObject root = WebDriverManager.instance.GetElement(elementId).gameObject;

            if (root == null)
            {
                if (WebDriverManager.instance.ImplicitTimeout == 0)
                {
                    WebDriverManager.instance.WriteElementNotFound(response);
                }
                else
                {
                    MainDispatcher.ExecuteCoroutine(ScheduleFindElement(body, args, response, InternalFindElementsFromElement));
                }

                return(true);
            }

            bool found = FindElementsFromRoot(body, new List <GameObject>()
            {
                root
            }, response);

            if (WebDriverManager.instance.ImplicitTimeout != 0 && found == false)
            {
                MainDispatcher.ExecuteCoroutine(ScheduleFindElement(body, args, response, InternalFindElementsFromElement));
            }

            return(true);
        }
示例#2
0
 private void GetAllUser(object source, OnGetUserEventArgs args)
 {
     if (!args.Update)
     {
         foreach (string name in args.Users)
         {
             if (!OnlineUsers.Any(u => u.Name == name))
             {
                 MainDispatcher.Invoke(() => { OnlineUsers.Add(new User {
                         Name = name
                     }); });
             }
         }
     }
     else
     {
         if (args.AddUser)
         {
             MainDispatcher.Invoke(() => { OnlineUsers.Add(new User {
                     Name = args.User
                 }); });
         }
         else
         {
             try
             {
                 var user = OnlineUsers.FirstOrDefault(u => u.Name == args.User);
                 MainDispatcher.Invoke(() => { OnlineUsers.Remove(user); });
             }
             catch
             {
             }
         }
     }
 }
        public static async Task <T> RunAsync <T>(this Func <T> func)
        {
            if (MainDispatcher == null || MainDispatcher.CheckAccess())
            {
                return(func());
            }

            return(await MainDispatcher.InvokeAsync(func));
        }
        private static void OnRecording(IntPtr context, IntPtr path)
        {
            var pathStr        = Marshal.PtrToStringAuto(path);
            var instanceHandle = (GCHandle)context;
            var instance       = instanceHandle.Target as MediaRecorderiOS;

            instanceHandle.Free();
            using (var dispatcher = new MainDispatcher())
                dispatcher.Dispatch(() => instance.callback(pathStr));
        }
        public static async Task RunAsync(this Action action)
        {
            if (MainDispatcher == null || MainDispatcher.CheckAccess())
            {
                action();
                return;
            }

            await MainDispatcher.InvokeAsync(action);
        }
 public void RunOnUi(Action action)
 {
     if (MainDispatcher != null)
     {
         MainDispatcher.BeginInvoke(action);
     }
     else
     {
         Dispatcher.CurrentDispatcher.BeginInvoke(action);
     }
 }
示例#7
0
 public override void Dispose()
 {
     Readback(null, ptr => {
         using (var dispatcher = new MainDispatcher())
             dispatcher.Dispatch(() => {
                 Texture2D.Destroy(framebuffer);
                 readbackDispatcher.Dispose();
                 handlerDispatcher.Dispose();
             });
     });
 }
示例#8
0
        // Use this for initialization
        void Start()
        {
            //init the webdriver server
            var instance = WebDriverManager.instance;

            FindElementCommands.Init();
            ElementAttributeCommands.Init();
            ElementInteractCommands.Init();
            MainDispatcher.ExecuteBlocking(() => {
                Debug.Log("started dispatcher");
            });

            WebDriverManager.instance.SessionStarted += HandleSessionStarted;
        }
        public static void SafeRun(this Action action)
        {
            if (MainDispatcher == null)
            {
                action();
                return;
            }

            if (!MainDispatcher.CheckAccess())
            {
                MainDispatcher.BeginInvoke(action);
                return;
            }
            action();
        }
示例#10
0
        public async Task Start(List <Action> Actions)
        {
            await Task.Run(() =>
            {
                string error;
                foreach (var a in Actions)
                {
                    try
                    {
                        MainDispatcher.Invoke(() => { ViewActions.Insert(0, a); });
                        MainDispatcher.Invoke(() => { a.Status = "Запуск..."; });
                        if (a.Path != null && a.Path != "")
                        {
                            error = Model.ProcessWorker.StartProcess(a.Path, a.Param);
                            MainDispatcher.Invoke(() => { a.Error = error; });
                            for (int i = 0; i < 100; i++)
                            {
                                Thread.Sleep(100);
                                if (Model.ProcessWorker.IsStartedProcessWork(a.Path))
                                {
                                    break;
                                }
                            }
                        }
                        else
                        {
                            //Обработка запуска процессов
                        }
                        MainDispatcher.Invoke(() => { a.Status = "Выполнено"; });
                        fl.Write($"Запущено {(a.Path != "" ? a.Path : a.ServiceName)}", Enums.LogType.Info);
                    }
                    catch (Exception ex)
                    {
                        MainDispatcher.Invoke(() => { a.Status = "Не выполнено"; });
                        MainDispatcher.Invoke(() => { a.Error = $"Ошибка: {ex.Message}"; });
                        fl.Write($"Ошибка при запуске {a.Path} - {ex.Message}", Enums.LogType.Info);
                    }
                    Thread.Sleep((int)a.Delay);
                }
                if (Actions.Count > 0)
                {
                    Thread.Sleep(1000);
                }
            });

            Done?.Invoke();
        }
示例#11
0
        /// <summary>
        /// Draws the collection of <see cref="IGraphicLine"/>s and <see cref="IGraphicPolygon"/>s
        /// to the screen.
        /// </summary>
        public async Task Draw(IEnumerable <IGraphicLine> lines, IEnumerable <IGraphicPolygon> polygons)
        {
            ColorCache = ColorCache ?? throw new InvalidOperationException("ColorCache is null");

            try
            {
                await MainDispatcher.InvokeAsync(() =>
                {
                    Bitmap.Clear();

                    foreach (var line in lines)
                    {
                        Bitmap.DrawLine(
                            line.Point1.X,
                            line.Point1.Y,
                            line.Point2.X,
                            line.Point2.Y,
                            ColorCache[line.Color]
                            );
                    }

                    foreach (var polygon in polygons)
                    {
                        var points = new int[polygon.Points.Count * 2 + 2];

                        for (int i = 0, c = 0; i < points.Length - 2; i += 2, c++)
                        {
                            var point = polygon.Points[c];

                            points[i]     = point.X;
                            points[i + 1] = point.Y;
                        }

                        var first = polygon.Points.First();
                        points[points.Length - 2] = first.X;
                        points[points.Length - 1] = first.Y;

                        Bitmap.DrawPolyline(points, ColorCache[polygon.Color]);
                    }
                });
            }
            catch (Exception)
            {
                //Ignore
            }
        }
示例#12
0
 void Awake()
 {
     if (instance == null) {
     #if UNITY_FLASH
     ActionScript.Import("com.edde.temphook.SocialNetwork");
         instance = this;
         currentSocialNetwork = SocialNetwork.create("VK");
     #endif
         instance = this;
         currentSocialNetwork = SocialNetwork.create("VK");
         #if UNITY_FLASH
         #elif UNITY_EDITOR
         MyDateTime.CheckMinValue();
         #else
         MyDateTime.CheckMinValue();
         #endif
     }
 }
示例#13
0
        public static bool FindElement(string body, string[] args, HttpListenerResponse response)
        {
            var rootBag = FindStartBag(body, response);

            if (rootBag == null)
            {
                return(true);
            }

            bool found = FindElementFromRoot(body, rootBag, response);

            if (WebDriverManager.instance.ImplicitTimeout != 0 && found == false)
            {
                MainDispatcher.ExecuteCoroutine(ScheduleFindElement(body, args, response, InternalFindElement));
            }

            return(true);
        }
示例#14
0
        private static void OnPhoto(IntPtr context, IntPtr imgPtr, int width, int height)
        {
            // Get device
            var cameraRef = (GCHandle)context;
            var camera    = cameraRef.Target as DeviceCameraiOS;

            if (!camera)
            {
                return;
            }
            // Marshal photo data
            var data = new byte[width * height * 4];

            Marshal.Copy(imgPtr, data, 0, data.Length);
            // Create photo
            using (var dispatch = new MainDispatcher())
                dispatch.Dispatch(() => {
                    var photo = new Texture2D(width, height, TextureFormat.BGRA32, false);
                    photo.LoadRawTextureData(data);
                    photo.Apply();
                    camera.photoCallback(photo);
                });
        }
示例#15
0
        public static bool HighlightElement(string body, string[] args, HttpListenerResponse response)
        {
            Component comp = GetComponent(args, response);

            if (comp == null)
            {
                return(true);
            }

            string responseBody = "{\"data\":null}";

            //highlight the element now
            float xMin = float.MaxValue;
            float xMax = float.MinValue;
            float yMin = float.MaxValue;
            float yMax = float.MinValue;
            float zMin = float.MaxValue;
            float zMax = float.MinValue;

            Camera cam = Camera.main;

            GameObject go = comp.gameObject;

            //list with all the bounds
            List <Bounds>    bounds     = new List <Bounds> ();
            List <Transform> transforms = new List <Transform> ();

            //bounds from colliders
            Collider[] colliders = go.GetComponentsInChildren <Collider> ();

            foreach (var c in colliders)
            {
                bounds.Add(c.bounds);
                transforms.Add(c.gameObject.transform);
            }

            //bounds from renderers
            Renderer[] renderers = go.GetComponentsInChildren <Renderer> ();

            foreach (var r in renderers)
            {
                bounds.Add(r.bounds);
                transforms.Add(r.gameObject.transform);
            }

            //for each bounds get the min and max
            //expand the bounding box
            var transformEnumerator = transforms.GetEnumerator();

            foreach (Bounds bound in bounds)
            {
                transformEnumerator.MoveNext();

                Vector3 min = bound.min;
                Vector3 max = bound.max;

                if (min.x < xMin)
                {
                    xMin = min.x;
                }

                if (min.y < yMin)
                {
                    yMin = min.y;
                }

                if (max.x > xMax)
                {
                    xMax = max.x;
                }

                if (max.y > yMax)
                {
                    yMax = max.y;
                }

                if (min.z < zMin)
                {
                    zMin = min.z;
                }

                if (max.z > zMax)
                {
                    zMax = max.z;
                }
            }

            RectTransform[] rectTransforms = go.GetComponentsInChildren <RectTransform> ();

            Vector3[] corners = new Vector3[4];

            foreach (var t in rectTransforms)
            {
                t.GetWorldCorners(corners);

                if (corners [0] [0] < xMin)
                {
                    xMin = corners [0] [0];
                }

                if (corners [0] [1] < yMin)
                {
                    yMin = corners [0] [1];
                }

                if (corners [2] [0] > xMax)
                {
                    xMax = corners [3] [0];
                }

                if (corners [2] [1] > yMax)
                {
                    yMax = corners [2] [1];
                }

                foreach (var c in corners)
                {
                    if (c.z < zMin)
                    {
                        zMin = c.z;
                    }

                    if (c.z > zMax)
                    {
                        zMax = c.z;
                    }
                }
            }

            Debug.Log(string.Format("xMin:{0} xMax:{1} yMin:{2} yMax:{3}", xMin, xMax, yMin, yMax));

            GameObject selection = GameObject.CreatePrimitive(PrimitiveType.Quad);

            selection.name = highlightId;

            Vector3 topLeftCorner     = new Vector3(xMin, yMin, zMin);
            Vector3 bottomRightCorner = new Vector3(xMax, yMax, zMin);

            Vector3 scale = selection.transform.localScale;

            scale.x = bottomRightCorner.x - topLeftCorner.x;
            scale.y = bottomRightCorner.y - topLeftCorner.y;

            Vector3 position = selection.transform.position;

            position.x = go.transform.position.x;
            position.y = go.transform.position.y;
            position.z = zMin - 0.1f;

            selection.transform.localScale = scale;
            selection.transform.position   = position;
            selection.layer = go.layer;

            _highlightMat = GameObject.Instantiate(Resources.Load <Material> ("WDHighlight"));
            selection.GetComponent <MeshRenderer> ().material = _highlightMat;

            MainDispatcher.ExecuteCoroutine(HighlightStuff());

            WebDriverManager.instance.WriteResponse(response, responseBody, 200);

            return(true);
        }
示例#16
0
 void Start()
 {
     if (instance == null) {
         instance = this;
     }
 }
示例#17
0
        public async void LoadXMLintoSQLite(XmlDocument xmlDoc, bool loadGeizhals)
        {
            try
            {
                List <ProduktModell> listXML = new List <ProduktModell>();

                Stopwatch xmlTime = new Stopwatch();

                xmlTime.Start();

                //XML auswerten und antragen
                XmlNodeList artikelDaten = xmlDoc.SelectNodes(".//item");

                int maxCount = artikelDaten.Count - 1;

                for (int i = 0; i < artikelDaten.Count; i++)
                {
                    ProduktModell model = new ProduktModell()
                    {
                        hardwareRatURL   = artikelDaten[i].ChildNodes[5].InnerText,
                        hardwareRatPrice = double.Parse(artikelDaten[i].ChildNodes[9].InnerText),
                        articlePicture   = artikelDaten[i].ChildNodes[6].InnerText,
                        articleName      = artikelDaten[i].ChildNodes[1].InnerText,
                        hardwareRatID    = int.Parse(artikelDaten[i].ChildNodes[0].InnerText),
                        gTIN             = artikelDaten[i].ChildNodes[11].InnerText,
                        AddedAt          = DateTime.Now,
                    };

                    listXML.Add(model);

                    await MainDispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
                    {
                        statusValue = $"Lade XML Artikel {i} von {maxCount}";
                    }));
                }

                int articleAdded = 0;
                int articleMax   = 0;
                //In Datenbank packen
                if (listXML.Count > 0)
                {
                    articleMax = listXML.Count;
                    HtmlAgilityPack.HtmlDocument document = null;
                    HtmlWeb webPage = null;

                    if (loadGeizhals)
                    {
                        webPage  = new HtmlWeb();
                        document = new HtmlAgilityPack.HtmlDocument();
                    }

                    foreach (ProduktModell row in listXML)
                    {
                        //Geizhalsbezug aufrufen
                        if (loadGeizhals)
                        {
                            try
                            {
                                ProduktModell retVal = SearchGeizhalsData(row.gTIN, row.articleName);
                                row.comparePrice   = retVal.comparePrice;
                                row.compareURL     = retVal.compareURL;
                                row.hasGeizhalsURL = retVal.hasGeizhalsURL;

                                double difference = Math.Round(row.hardwareRatPrice - row.comparePrice, 2);
                                row.priceDifference = difference;
                                if (difference <= 0)
                                {
                                    row.State = "günstiger";
                                }
                                else if (difference > 0 && difference < 3)
                                {
                                    row.State = "1-2€ darüber";
                                }
                                else if (difference > 2)
                                {
                                    row.State = "3€ oder mehr darüber";
                                }

                                //Falls kein Preis bei Geizhals vorhanden
                                if (row.comparePrice == 0)
                                {
                                    row.State = "günstiger";
                                }

                                //1.2 Sekunden warten IP Ban zu umgehen
                                System.Threading.Thread.Sleep(1800);
                            }
                            catch (Exception)
                            {
                            }
                        }

                        if (!produktItems.Any(y => y.hardwareRatID == row.hardwareRatID))
                        {
                            row.IsNew   = true;
                            row.AddedAt = DateTime.Now;
                            sQLiteHelper.InsertItem(row);
                            articleAdded++;

                            await MainDispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
                            {
                                statusValue = $"Übernehme Artikel {articleAdded} von {articleMax} ({Math.Round(((double)articleAdded / articleMax * 100), 0)}%)";
                            }));
                        }
                        else
                        {
                            //Artikel nur updaten
                            row.IsNew = false;
                            sQLiteHelper.UpdateItemXML(row, loadGeizhals);

                            await MainDispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
                            {
                                statusValue = $"Update Artikel HardwareRat ID {row.hardwareRatID}, da er bereits vorhanden ist!";
                            }));
                        }
                    }
                }
                xmlTime.Stop();
                log.writeLog(LogType.ERROR, $"XML Abruf hat {xmlTime.Elapsed.ToString("hh")}h {xmlTime.Elapsed.ToString("mm")}m {xmlTime.Elapsed.ToString("ss")}s {xmlTime.Elapsed.ToString("ff")}ms gedauert.");

                await MainDispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
                {
                    statusValue = $"{articleAdded} / {maxCount} Artikel übernommen ({Math.Round(((double)articleAdded / articleMax * 100), 0)}%)";
                }));

                LoadGridItems(false, false);
            }
            catch (Exception)
            {
            }
        }
示例#18
0
        public async void LoadGridItems(bool loadSiteData, bool onlyUpdateEmpty)
        {
            try
            {
                List <ProduktModell> tmpProduktItems = new List <ProduktModell>();
                bool waitTask = false;

                //Sqls laden
                string sSQL = "SELECT hardwareRatURL, compareSiteURL, hardwareRatPrice, compareSitePrice, state, differencePrice, compareSiteType, produktID, articleName, articleURL, hardwareRatID, addedAt, hasGeizhalsURL, IsNew, GTIN FROM PRODUKTE";

                List <ProduktModell> retValProducts = sQLiteHelper.getGridData(sSQL);
                if (retValProducts != null)
                {
                    int countFor = 1;

                    if (loadSiteData)
                    {
                        DialogResult dialogResult = System.Windows.Forms.MessageBox.Show("Möchten sie mit Zeitversatz arbeiten, um Geizhals Ban zu umgehen?", "Hinweis!", MessageBoxButtons.YesNo);
                        if (dialogResult == DialogResult.Yes)
                        {
                            waitTask = true;
                        }
                    }

                    foreach (ProduktModell row in retValProducts)
                    {
                        await MainDispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
                        {
                            statusValue = $"Lade Artikel {countFor} von {retValProducts.Count} ({Math.Round(((double)countFor / retValProducts.Count * 100), 0)}%)";
                        }));

                        if (loadSiteData)
                        {
                            //Daten abrufen
                            ProduktModell retVal = getHTMLData(row, onlyUpdateEmpty);
                            row.comparePrice     = retVal.comparePrice;
                            row.hardwareRatPrice = retVal.hardwareRatPrice;
                            row.articleName      = retVal.articleName;

                            if (waitTask && !row.hasGeizhalsURL && onlyUpdateEmpty)
                            {
                                System.Threading.Thread.Sleep(2500);
                            }
                            else if (waitTask && !onlyUpdateEmpty)
                            {
                                System.Threading.Thread.Sleep(2500);
                            }
                        }

                        //Status abrufen
                        double difference = Math.Round(row.hardwareRatPrice - row.comparePrice, 2);
                        row.priceDifference = difference;
                        if (difference <= 0)
                        {
                            row.State = "günstiger";
                        }
                        else if (difference > 0 && difference < 3)
                        {
                            row.State = "1-2€ darüber";
                        }
                        else if (difference > 2)
                        {
                            row.State = "3€ oder mehr darüber";
                        }

                        //Falls kein Preis bei Geizhals vorhanden
                        if (row.comparePrice == 0)
                        {
                            row.State = "günstiger";
                        }

                        sQLiteHelper.UpdateItem(row);

                        tmpProduktItems.Add(row);
                        countFor++;
                    }

                    rowsLoaded = $"{retValProducts.Count} Produkte geladen [{retValProducts.Count(y => y.State == "günstiger")} günstiger; {retValProducts.Count(y => y.State == "1-2€ darüber")} 1-2€ darüber; {retValProducts.Count(y => y.State == "3€ oder mehr darüber")} 3€ oder mehr]!";

                    await MainDispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
                    {
                        statusValue = "Übersicht erfolgreich aktualisiert!";
                        produktItems = new ObservableCollection <ProduktModell>(tmpProduktItems);
                        CollectionViewSource productCView = new CollectionViewSource()
                        {
                            Source = tmpProduktItems
                        };
                        productGrid = productCView.View;
                    }));
                }
                else
                {
                    produktItems = new ObservableCollection <ProduktModell>();
                    await MainDispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
                    {
                        statusValue = "Keine Daten vorhanden!";
                        productGrid = null;
                    }));

                    return;
                }
                return;
            }
            catch (Exception ex)
            {
                log.writeLog(LogType.ERROR, MethodBase.GetCurrentMethod().Name + ": Fehler beim Laden der Sensoren", ex);
                return;
            }
        }
示例#19
0
        private void GenerateWaveformData(string path, int points = waveformCompressedPointCount)
        {
            if (generateWaveCancelTokenSource != null && !generateWaveCancelTokenSource.IsCancellationRequested)
            {
                generateWaveCancelTokenSource.Cancel();
            }
            generateWaveCancelTokenSource = new CancellationTokenSource();

            Task.Run(() =>
            {
                int stream         = Bass.BASS_StreamCreateFile(path, 0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_PRESCAN);
                int frameLength    = (int)Bass.BASS_ChannelSeconds2Bytes(stream, 0.02);
                long streamLength  = Bass.BASS_ChannelGetLength(stream, 0);
                int frameCount     = (int)(streamLength / (double)frameLength);
                int waveformLength = frameCount * 2;
                float[] waveform   = new float[waveformLength];
                float[] levels     = new float[2];

                int actualPoints = Math.Min(points, frameCount);

                int compressedPointCount         = actualPoints * 2;
                float[] waveformCompressedPoints = new float[compressedPointCount];
                List <int> waveMaxPointIndexes   = new List <int>();
                for (int i = 1; i <= actualPoints; i++)
                {
                    waveMaxPointIndexes.Add((int)Math.Round(waveformLength * (i / (double)actualPoints), 0));
                }

                float maxLeftPointLevel  = float.MinValue;
                float maxRightPointLevel = float.MinValue;
                int currentPointIndex    = 0;
                for (int i = 0; i < waveformLength; i += 2)
                {
                    Bass.BASS_ChannelGetLevel(stream, levels);
                    waveform[i]     = levels[0];
                    waveform[i + 1] = levels[1];

                    if (levels[0] > maxLeftPointLevel)
                    {
                        maxLeftPointLevel = levels[0];
                    }
                    if (levels[1] > maxRightPointLevel)
                    {
                        maxRightPointLevel = levels[1];
                    }

                    if (i > waveMaxPointIndexes[currentPointIndex])
                    {
                        waveformCompressedPoints[(currentPointIndex * 2)]     = maxLeftPointLevel;
                        waveformCompressedPoints[(currentPointIndex * 2) + 1] = maxRightPointLevel;
                        maxLeftPointLevel  = float.MinValue;
                        maxRightPointLevel = float.MinValue;
                        currentPointIndex++;
                    }
                    if (i % 3000 == 0)
                    {
                        float[] clonedData = (float[])waveformCompressedPoints.Clone();
                        if (MainDispatcher == null)
                        {
                            WaveformData = clonedData;
                        }
                        else
                        {
                            MainDispatcher.Invoke(() => { WaveformData = clonedData; });
                        }
                    }
                    if (generateWaveCancelTokenSource.IsCancellationRequested)
                    {
                        break;
                    }
                }
                float[] finalClonedData = (float[])waveformCompressedPoints.Clone();
                if (MainDispatcher == null)
                {
                    FullLevelData = waveform;
                    WaveformData  = finalClonedData;
                }
                else
                {
                    MainDispatcher.Invoke(() =>
                    {
                        FullLevelData = waveform;
                        WaveformData  = finalClonedData;
                    });
                }
                Bass.BASS_StreamFree(stream);
            }, generateWaveCancelTokenSource.Token);
        }
示例#20
0
        private void StartWebDriver()
        {
            listener.Start();

            ThreadPool.QueueUserWorkItem((_) => {
                while (true)
                {
                    HttpListenerContext ctx = listener.GetContext();

                    ThreadPool.QueueUserWorkItem((idontcare) => {
                        string command = ctx.Request.Url.Segments[1].Replace("/", "");

                        var request = ctx.Request;

                        var response = ctx.Response;

                        var body = new StreamReader(request.InputStream).ReadToEnd();

                        var args = request.Url.Segments.Skip(2).Select(x => x.Replace("/", "")).ToArray <string>();

                        switch (command)
                        {
                        case "status":
                            switch (request.HttpMethod)
                            {
                            case "GET":
                                RespondToStatus(body, response);
                                break;

                            default:
                                RespondUnkownMethod(response);
                                break;
                            }
                            break;

                        case "session":
                            switch (args.Count())
                            {
                            case 0:
                                switch (request.HttpMethod)
                                {
                                case "POST":
                                    NewSession(body, response);
                                    break;

                                default:
                                    RespondUnkownMethod(response);
                                    break;
                                }
                                break;

                            case 1:
                                if (request.HttpMethod == "DELETE")
                                {
                                    var sessionId = args[0];

                                    DeleteSession(sessionId, response);
                                }
                                else
                                {
                                    RespondUnkownMethod(response);
                                }
                                break;

                            default:
                                //other commands over here

                                //getting the session id here
                                //if not a match return error
                                var reqSessId = args[0];

                                if (reqSessId.Equals(sessionId) == false)
                                {
                                    BadSessionId(body, response);

                                    return;
                                }

                                //search if someone registered a handle for
                                //the command
                                args = args.Skip(1).ToArray();

                                var realCommand = args[0];

                                if (commands.ContainsKey(realCommand))
                                {
                                    if (commands[realCommand].ContainsKey(request.HttpMethod))
                                    {
                                        var registeredCommands = commands[realCommand][request.HttpMethod];

                                        var restOfCommandSeg = args.Skip(1);

                                        string restOfCommand = "";

                                        if (restOfCommandSeg.Count() > 0)
                                        {
                                            restOfCommand = restOfCommandSeg.Aggregate((i, j) => i + "/" + j);
                                        }

                                        //the command to be executed
                                        Func <string, string[], HttpListenerResponse, bool> registeredCommand = null;

                                        //searching for a match
                                        foreach (var entry in registeredCommands)
                                        {
                                            if (entry.Key.IsMatch(restOfCommand))
                                            {
                                                registeredCommand = entry.Value;
                                                break;
                                            }
                                        }

                                        if (registeredCommand == null)
                                        {
                                            RespondUnkownMethod(response);

                                            return;
                                        }

                                        MainDispatcher.ExecuteBlocking(() => {
                                            //need to see which ones of the reg exp match
                                            registeredCommand(body, args.Skip(1).ToArray(), response);
                                        });
                                    }
                                    else
                                    {
                                        RespondUnkownMethod(response);
                                    }
                                }
                                else
                                {
                                    CommandNotImplemented(realCommand, response);
                                }

                                break;
                            }
                            break;

                        default:
                            CommandNotImplemented(command, response);
                            break;
                        }
                    });
                }
            });
        }