Ejemplo n.º 1
0
 public static void DownloadFile(string serverUrl, string saveFile, Action <string> onDownload, Action <float> onProgress = null)
 {
     WWWUtil.Get(serverUrl).SubscribeWithProgress(x =>
     {
         bool sucess = SaveFile(saveFile, x.www.bytes);
         if (sucess)
         {
             if (onDownload != null)
             {
                 onDownload("download sucess");
             }
         }
         else
         {
             if (onDownload != null)
             {
                 onDownload("save file error");
             }
         }
     }, error =>
     {
         if (onDownload != null)
         {
             onDownload(error.error);
         }
     }, progress =>
     {
         if (onProgress != null)
         {
             onProgress(progress.www.progress);
         }
     });
 }
Ejemplo n.º 2
0
 static int QPYX_Get_YXQP(IntPtr L_YXQP)
 {
     try
     {
         ToLua.CheckArgsCount(L_YXQP, 1);
         string       QPYX_arg0_YXQP = ToLua.CheckString(L_YXQP, 1);
         WWWOperation QPYX_o_YXQP    = WWWUtil.Get(QPYX_arg0_YXQP);
         ToLua.PushObject(L_YXQP, QPYX_o_YXQP);
         return(1);
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
Ejemplo n.º 3
0
 static int Get(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         string       arg0 = ToLua.CheckString(L, 1);
         WWWOperation o    = WWWUtil.Get(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 4
0
    public override string GetIpsByHttpDNS(string url)
    {
        if (url.StartsWith("http://"))
        {
            url = url.Replace("http://", "");
        }
        if (ipCache.ContainsKey(url))
        {
            return(ipCache[url]);
        }
        //181184
        //198540
        WWWUtil.Get("http://203.107.1.1/181184/d?host=" + url).Subscribe(x => {
            if (x.text.StartsWith("{"))
            {
                HttpData HttpData = JsonUtility.FromJson <HttpData>(x.text);
                // Debug.Log(HttpData.host);
                // Dictionary<string, object> dic = JsonUtility.Deserialize(x.text) as Dictionary<string, object>;
                // if (dic.ContainsKey("host")) {
                //  var ips = dic["ips"] as List<object>;
                nextUpdateTime = Time.realtimeSinceStartup + HttpData.ttl;
                string ipList  = "";
                foreach (var ip in HttpData.ips)
                {
                    if (!string.IsNullOrEmpty(ipList))
                    {
                        ipList += ",";
                    }
                    if (!string.IsNullOrEmpty(ip as string))
                    {
                        ipList += ip as string;
                    }
                }
                string data = JsonUtility.ToJson(new CustomEventData()
                {
                    eventName = "onGetIpsByHttpDNSResult",
                    data      = ipList
                });


                GameSDKCallback.instance.OnSdkCallbackCall(data);

                data = JsonUtility.ToJson(new CustomEventData()
                {
                    eventName = "onAppstorePaySucess",
                    data      = ""
                });
                GameSDKCallback.instance.OnSdkCallbackCall(data);
                if (!string.IsNullOrEmpty(ipList))
                {
                    if (ipCache.ContainsKey(url))
                    {
                        ipCache[url] = ipList;
                    }
                    else
                    {
                        ipCache.Add(url, ipList);
                    }
                }
            }
        }, e => {
            Debug.LogError("GetIpsByHttpDNS:" + e.error);
        });

        return(url);
    }