public static KinstrumentsWebserver GetInstance()
        {
            lock (lck)
            {
                if (instance == null)
                {
                    instance = new KinstrumentsWebserver(8881, !KService.IsMono);
                    var sep = System.IO.Path.DirectorySeparatorChar.ToString();
                    var wd = System.IO.Path.Combine(KSPUtil.ApplicationRootPath,
                        "GameData/"+
                        "Kinstruments/" +
                        "Plugins/" +
                        "www");

                    var tmp = wd.Split('/');
                    wd = string.Join(sep, tmp);

                    instance.Service.WwwRootDirectory = wd;

                    instance.Service.Log.Print("wwwrootdir = {0}", instance.Service.WwwRootDirectory);
                    instance.Start();
                }
                return instance;
            }
        }
 public override void OnStart(PartModule.StartState state)
 {
     if (httpd == null)
     {
         httpd = KinstrumentsWebserver.GetInstance();
     }
     base.OnStart(state);
 }
Exemple #3
0
        static void Main(string[] args)
        {
            var s = new KinstrumentsWebserver(8881, true);
            s.Service.Log = new KInstrumentsService.BCLLogger();
            s.Service.WwwRootDirectory = System.IO.Path.Combine(Environment.CurrentDirectory, "www");
            s.Start();

            string k = string.Empty;
            do
            {
                var d = s.Service.GetData();
                d.VesselName = "Test Vessel";
                k = Console.ReadKey(true).KeyChar.ToString();
                if (k == "q")
                {
                    d.Roll -= 2;
                }
                if (k == "e")
                {
                    d.Roll += 2;
                }

                if (k == "w")
                {
                    d.Pitch -= 4;
                    d.Altitude -= 100;
                }

                if (k == "s")
                {
                    d.Pitch += 4;
                    d.Altitude += 100;
                }

                Console.Error.WriteLine("p={0} r={1}", d.Pitch, d.Roll);

            } while (true);
        }
 public void NoOp()
 {
     var ks = new KinstrumentsWebserver(8889, true);
     ks.Service.WwwRootDirectory = "C:\\Users\\inb\\Dropbox\\git\\ksp\\KinstrumentsTests\\bin\\Debug\\wwwroot";
     System.Threading.Thread.Sleep(15000);
     ks.Stop();
 }