public static void notifyBrowser() { App.main.Dispatcher.Invoke(() => { if (callbackarg) { Awesomium.Core.JSObject status = new Awesomium.Core.JSObject(); status["running"] = running; status["paused"] = paused; status["done"] = done; status["currentLoop"] = currentLoop; status["loopAmount"] = loopAmount; callbackarg?.Invoke("call", callbackarg, status); } }); }
public static async Task <bool> login(string username, string password, string hwid, Awesomium.Core.JSObject callbackarg) { var values = new Dictionary <string, string>(); values.Add("username", username); values.Add("password", password); values.Add("hwid", hwid); var content = new FormUrlEncodedContent(values); using (var client = new HttpClient()) { try { client.DefaultRequestHeaders.TryAddWithoutValidation("Accept", "text/html,application/xhtml+xml,application/xml"); client.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Encoding", "gzip, deflate"); client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0"); client.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Charset", "ISO-8859-1"); var httpResponseMessage = await client.PostAsync("http://handsfreeleveler.com:4446/api/remotelogin", content); if (httpResponseMessage.StatusCode == HttpStatusCode.OK) { string data = await httpResponseMessage.Content.ReadAsStringAsync(); var res = JSONSerializer <serviceRes> .DeSerialize(data); if (res.err != null && res.userData == null) { callbackarg?.Invoke("call", callbackarg, false); MessageBox.Show(res.err); return(false); } else { if (res.userData != null) { App.Client = JSONSerializer <User> .DeSerialize(data); callbackarg?.Invoke("call", callbackarg, data); LoginContract loginDetails = new LoginContract(); loginDetails.username = username; loginDetails.password = password; Storage.SerializeObject(loginDetails, "loginDetails.xml"); return(true); } else { callbackarg?.Invoke("call", callbackarg, false); return(false); } } } else { MessageBox.Show("Server not responding to your request."); callbackarg?.Invoke("call", callbackarg, false); return(false); } } catch (Exception ex) { callbackarg?.Invoke("call", callbackarg, false); return(false); } } }