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; } }
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); }