public WebController(RosBridgeUtility.RosBridgeConfig conf, RosBridgeUtility.RosBridgeLogic parent)
        {
            this.conf   = conf;
            this.parent = parent;
            // Initialize webserver
            NeobotixStateServer          = new HttpServer(4649);
            NeobotixStateServer.RootPath = "../../Public";
            Console.WriteLine(NeobotixStateServer.RootPath);

            LastMsgs  = new RosBridgeUtility.ServerStorage();
            LastRGB   = new RosBridgeUtility.ImageStorage();
            LastDepth = new RosBridgeUtility.ImageStorage();
            NeobotixStateServer.OnGet += (sender, e) =>
            {
                var req = e.Request;
                Console.WriteLine(e.Request.QueryString);
                var res  = e.Response;
                var path = req.RawUrl;
                if (path == "/")
                {
                    path += "index.html";
                }
                path = NeobotixStateServer.RootPath + path;
                //var content = NeobotixStateServer.GetFile(path);
                Console.WriteLine(path);
                Console.WriteLine(File.Exists(path));
                var content = System.IO.File.ReadAllBytes(path);

                if (content == null)
                {
                    res.StatusCode = (int)HttpStatusCode.NotFound;
                    return;
                }
                if (path.EndsWith(".html"))
                {
                    res.ContentType     = "text/html";
                    res.ContentEncoding = Encoding.UTF8;
                }
                res.OutputStream.Write(content, 0, content.Length);
            };
            NeobotixStateServer.OnPut += NeobotixStateServer_OnPut;
            NeobotixStateServer.AddWebSocketService <RosBridgeUtility.OdometryBehavior>(("/neobot_odom"),
                                                                                        () => new RosBridgeUtility.OdometryBehavior(LastMsgs));
            NeobotixStateServer.AddWebSocketService <RosBridgeUtility.StateBehavior>(("/server_state"),
                                                                                     () => new RosBridgeUtility.StateBehavior(LastMsgs));
            NeobotixStateServer.AddWebSocketService <RosBridgeUtility.TeleopKeyBehavior>(("/neobot_teleop"),
                                                                                         () => new RosBridgeUtility.TeleopKeyBehavior(LastMsgs, this));
            NeobotixStateServer.AddWebSocketService <RosBridgeUtility.LaserScanBehavior>(("/neobot_laser"),
                                                                                         () => new RosBridgeUtility.LaserScanBehavior(LastMsgs));
            NeobotixStateServer.AddWebSocketService <RosBridgeUtility.ImageBehavior>(("/kinect_image"),
                                                                                     () => new RosBridgeUtility.ImageBehavior(LastRGB));
            NeobotixStateServer.AddWebSocketService <RosBridgeUtility.ImageBehavior>(("/kinect_depth"),
                                                                                     () => new RosBridgeUtility.ImageBehavior(LastDepth));
        }
        public void updateImageState(ref BitmapSource source, Int32 height, Int32 width, RosBridgeUtility.ImageStorage target)
        {
            target.lastImageMsg        = new RosBridgeUtility.ImageState();
            target.lastImageMsg.height = height;
            target.lastImageMsg.width  = width;
            var encoder = new JpegBitmapEncoder();
            var frame   = BitmapFrame.Create(source);

            encoder.Frames.Add(frame);
            using (var stream = new MemoryStream())
            {
                encoder.Save(stream);
                target.lastImageMsg.pixels = Convert.ToBase64String(stream.ToArray());
            }
        }