async public static void Request(string url, BeaconData data, Action success, Action fail) { var json = JsonConvert.SerializeObject(data); Debugger.Log("beancon {0}", json); HttpContent httpContent = new StringContent(json, Encoding.UTF8, "application/json"); var response = await Client.PostAsync(url, httpContent); var responseString = await response.Content.ReadAsStringAsync(); }
public static void Request(int status, float start, int duration, List <BatchEvent> events, Action <bool> callback = null) { if (start <= 0) { start = GetTime(); } var msgData = new MsgData { id = GetRandom(), start = start, status = status, duration = duration, events = events }; // if (events.Count > 0) { // Debugger.Log ("Beacon data: {0}", events[0].param); // } var msgs = new List <Msg> { new Msg { type = 2, data = msgData, } }; var sysInfo = GetSystemInfo(); var deviceId = GetUuid(); var data = new BeaconData { userInfo = GetUserInfo(), location = GetLocation(), msgs = msgs }; void Success() { callback?.Invoke(true); } void Fail() { callback?.Invoke(false); } var task = Task.Run(() => Adapter.Request(BeaconSdk.serverUrl, data, Success, Fail)); task.Wait(); }