private void _IGtPush(string domainUrl, string appKey, string masterSecret, bool useSSL, ILogger logger) { this.appKey = appKey; this.masterSecret = masterSecret; this._logger = logger; httpProxy = new HttpProxy(new IGtHttpProxy()); var defaultConnectionLimit = ServicePointManager.DefaultConnectionLimit; if (defaultConnectionLimit < 100) { ServicePointManager.DefaultConnectionLimit = 1024; } if (domainUrl == null || domainUrl.Trim().Length == 0) { domailUrlList = GtConfig.getDefaultDomainUrl(useSSL); } else { domailUrlList = new List <string> { domainUrl } }; initOSDomain(null); }
public string getUserCountByTags(string appId, List <string> tagList) { var postData = new Dictionary <string, object> { { "action", nameof(getUserCountByTags) }, { "appkey", appKey }, { nameof(appId), appId }, { nameof(tagList), tagList } }; var tagListLimit = GtConfig.getTagListLimit(); if (tagListLimit < tagList.Count) { throw new Exception("tagList size:" + tagList.Count + "beyond the limit" + tagListLimit); } return(httpPostJSON(postData)); }
public bool connect() { var num = ConvertDateTimeInt(DateTime.Now); var md5SignValue = getMD5SignValue(new Dictionary <string, string> { { "appkey", appKey }, { "timeStamp", string.Concat(num) }, { "masterSecret", masterSecret } }); var paramData = new Dictionary <string, object> { { "action", nameof(connect) }, { "appkey", appKey }, { "timeStamp", num }, { "sign", md5SignValue }, { "version", GtConfig.getSDKVersion() } }; JsonConvert.SerializeObject(paramData); var input = httpPost(host, paramData, false); var dictionary = JsonConvert.DeserializeObject <Dictionary <string, object> >(input); if (input.IndexOf("success") <= -1) { throw new Exception("appKey or masterSecret is auth failed."); } AuthToken = (string)dictionary["authtoken"]; return(true); }
// Token: 0x060004C8 RID: 1224 RVA: 0x0000A114 File Offset: 0x00008314 public IGtHttpProxy() { string httpProxyIp = GtConfig.getHttpProxyIp(); int httpProxyPort = GtConfig.getHttpProxyPort(); if (!string.IsNullOrWhiteSpace(httpProxyIp)) { Host = httpProxyIp; Port = httpProxyPort; User = GtConfig.getHttpProxyUser(); _passwd = GtConfig.getHttpProxyPasswd(); } }
public string pushAPNMessageToList( string appId, string contentId, List <string> deviceTokenlist) { foreach (var str in deviceTokenlist) { if (str == null || str.Length != 64) { throw new Exception("deviceToken length must be 64"); } } return(httpPostJSON(new Dictionary <string, object> { { "action", "apnPushToListAction" }, { "appkey", appKey }, { nameof(appId), appId }, { nameof(contentId), contentId }, { "DTL", deviceTokenlist }, { "needDetails", GtConfig.isPushListNeedDetails() }, { "async", GtConfig.isPushListAsync() } })); }
// Token: 0x060004A8 RID: 1192 RVA: 0x00009AEC File Offset: 0x00007CEC public string submit() { string value = Guid.NewGuid().ToString(); seqId = 0; Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary.Add("requestId", value); dictionary.Add("appkey", APPKEY); dictionary.Add("action", "pushMessageToSingleBatchAction"); dictionary.Add("serialize", "pb"); dictionary.Add("async", GtConfig.isPushSingleBatchAsync()); SingleBatchRequest singleBatchRequest = SingleBatchRequest.CreateBuilder().SetBatchId(batchId).AddRangeBatchItem(innerMsgList).Build(); dictionary.Add("singleDatas", Convert.ToBase64String(singleBatchRequest.ToByteArray())); lastPostData = dictionary; innerMsgList.Clear(); return(push.httpPostJSON(push.host, dictionary, true)); }
public void close() { httpPostJSON(new Dictionary <string, object> { { "action", nameof(close) }, { "appkey", appKey }, { "version", GtConfig.getSDKVersion() }, { "authToken", AuthToken } }); }
public string blackCidList(string appId, List <string> cidList, int optType) { var lenOfBlackCidList = GtConfig.getMaxLenOfBlackCidList(); if (lenOfBlackCidList < cidList.Count) { return(httpPostJSON(new Dictionary <string, object> { { "result", "cid size:" + cidList.Count + " beyond the limit:" + lenOfBlackCidList } })); } return(httpPostJSON(new Dictionary <string, object> { { "action", "blackCidAction" }, { "appkey", appKey }, { nameof(appId), appId }, { nameof(cidList), cidList }, { nameof(optType), optType } })); }
public string httpPostJSON(string url, Dictionary <string, object> postData, bool gzip) { postData.Add("version", GtConfig.getSDKVersion()); JsonConvert.SerializeObject(postData); postData.Add("authToken", AuthToken); var input = httpPost(url, postData, gzip); if (string.IsNullOrEmpty(input)) { if (postData.ContainsKey("requestId")) { throw new RequestException((string)postData["requestId"], "Http request exception,address is " + url); } return(input); } if (input.IndexOf("sign_error") > -1) { if (connect()) { postData.Remove("authToken"); postData.Add("authToken", AuthToken); return(httpPost(url, postData, gzip)); } } else if (input.IndexOf("domain_error") > -1) { var dictionary = JsonConvert.DeserializeObject <Dictionary <string, object> >(input); appkeyUrlList.Add(appKey, CastToList(((JArray)dictionary["osList"]).ToObject <List <dynamic> >())); dynamicGetFastest(null); return(httpPost(host, postData, gzip)); } return(input); }
public string pushMessageToList(string contentId, List <Target> targetList) { var flag1 = GtConfig.isPushListAsync(); var flag2 = GtConfig.isPushListNeedAliasDetails(); var flag3 = GtConfig.isPushListNeedDetails(); var postData = new Dictionary <string, object> { { "action", "pushMessageToListAction" }, { "appkey", appKey }, { nameof(contentId), contentId }, { "needDetails", flag3 }, { "needAliasDetails", flag2 }, { "async", flag1 } }; var num = !flag1 || flag3?GtConfig.getSyncListLimit() : GtConfig.getAsyncListLimit(); if (targetList.Count > num) { return("target size:" + targetList.Count + " beyond the limit:" + num); } var stringList1 = new List <string>(); var stringList2 = new List <string>(); var str = ""; foreach (var target in targetList) { var clientId = target.clientId; var alias = target.alias; if (!string.IsNullOrWhiteSpace(clientId)) { stringList1.Add(clientId); } else if (!string.IsNullOrWhiteSpace(alias)) { stringList2.Add(alias); } if (string.IsNullOrWhiteSpace(str)) { str = target.appId; } } postData.Add("appId", str); postData.Add("clientIdList", stringList1); postData.Add("aliasList", stringList2); postData.Add("type", 2); return(httpPostJSON(host, postData, true)); }
private string httpPost(string postUrl, Dictionary <string, object> paramData, bool gzip) { var str1 = (string)paramData["action"]; var str2 = ""; var httpTryCount = GtConfig.getHttpTryCount(); var num1 = 0; while (num1 <= httpTryCount) { var httpWebResponse = (HttpWebResponse)null; var streamReader = (StreamReader)null; var stream1 = (Stream)null; var httpWebRequest = (HttpWebRequest)null; try { Util.SetCertificatePolicy(); var num2 = ConvertDateTimeInt(DateTime.Now); httpWebRequest = (HttpWebRequest)WebRequest.Create(new Uri(postUrl)); var webProxy = httpProxy.getWebProxy(); if (webProxy != null) { httpWebRequest.Proxy = webProxy; } var str3 = JsonConvert.SerializeObject(paramData); var buffer = Encoding.UTF8.GetBytes(str3); if (str1 != null) { httpWebRequest.Headers.Add("Gt-Action", str1); } if (gzip) { httpWebRequest.Headers.Add("Content-Encoding", nameof(gzip)); httpWebRequest.Headers.Add("Accept-Encoding", nameof(gzip)); buffer = Zip(str3); } httpWebRequest.Method = "POST"; httpWebRequest.ContentType = "text/html;charset=UTF-8"; httpWebRequest.Timeout = GtConfig.getHttpConnectionTimeOut(); httpWebRequest.ReadWriteTimeout = GtConfig.getHttpSoTimeOut(); httpWebRequest.ContentLength = buffer.Length; httpWebRequest.ProtocolVersion = HttpVersion.Version10; httpWebRequest.KeepAlive = true; stream1 = httpWebRequest.GetRequestStream(); var num3 = ConvertDateTimeInt(DateTime.Now); stream1.Write(buffer, 0, buffer.Length); stream1.Close(); httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse(); Console.WriteLine("RESPONSE HEADER: " + httpWebResponse.Headers); var stream2 = httpWebResponse.GetResponseStream(); if (gzip) { stream2 = new GZipStream(stream2, CompressionMode.Decompress); } streamReader = new StreamReader(stream2, Encoding.UTF8); str2 = streamReader.ReadToEnd(); var num4 = ConvertDateTimeInt(DateTime.Now); return(str2); } catch (Exception ex) { ++num1; _logger?.LogError(ex, "HTTP 请求异常信息"); } finally { streamReader?.Close(); httpWebResponse?.Close(); stream1?.Close(); httpWebRequest?.Abort(); } } return(str2); }