예제 #1
0
 public void Start()
 {
     //_hookID = SetHook(_proc);
     try
     {
         if (ServiceProvider.Settings.UseWebserver)
         {
             WebServer.Start(ServiceProvider.Settings.WebserverPort);
         }
         KeyboardHook.KeyDownEvent += KeyDown;
         KeyboardHook.KeyUpEvent   += KeyUp;
     }
     catch (Exception)
     {
         Log.Error("Unable to start webserver");
     }
 }
예제 #2
0
 public void Start()
 {
     //_hookID = SetHook(_proc);
     try
     {
         KeyboardHook.KeyDownEvent += KeyDown;
         KeyboardHook.KeyUpEvent   += KeyUp;
         if (ServiceProvider.Settings.UseWebserver)
         {
             WebServer.Start(ServiceProvider.Settings.WebserverPort);
             string file = Path.Combine(Settings.ApplicationFolder, "ngrok.exe");
             _ngrok_process = PhotoUtils.Run(file, "http " + ServiceProvider.Settings.WebserverPort,
                                             ProcessWindowStyle.Hidden);
             if (_ngrok_process == null)
             {
                 return;
             }
             Thread.Sleep(2000);
             using (var client = new WebClient())
             {
                 string  data = client.DownloadString("http://127.0.0.1:4040/api/tunnels");
                 dynamic json = Newtonsoft.Json.JsonConvert.DeserializeObject(data);
                 string  url  = json.tunnels[0].public_url;
                 if (!string.IsNullOrEmpty(url))
                 {
                     client.DownloadString(
                         string.Format("http://digicamcontrol.com/remote/submit.php?id={0}&url={1}",
                                       ServiceProvider.Settings.ClientId, url));
                 }
             }
         }
     }
     catch (Exception)
     {
         Log.Error("Unable to start webserver");
     }
 }