Ejemplo n.º 1
0
 //return run ok ?
 public bool AddUploadTask(string json, VoidFuncN <bool> cb, long file_uuid, GameObject host)
 {
     if (string.IsNullOrEmpty(json))
     {
         return(false);
     }
     if (isWorking)
     {
         return(false);
     }
     if (cb == null)
     {
         return(false);
     }
     if (this.cb != null)
     {
         return(false);
     }
     if (file_uuid < 0)
     {
         return(false);
     }
     if (host == null)
     {
         return(false);
     }
     isWorking      = true;
     this.cb        = cb;
     this.file_uuid = file_uuid;
     StartCoroutine(RunUploadTask(json));
     return(true);
 }
Ejemplo n.º 2
0
    IEnumerator RunUploadTask(string json)
    {
        WWWForm form = new WWWForm();

        form.AddField("json_data", json);
        form.AddField("file_name", file_uuid.ToString());

        WWW www = new WWW(upload_url, form);

        yield return(www);

        if (www.text == "ok")
        {
            if (host != null)
            {
                cb.Invoke(true);
            }
        }
        else if (www.text == "error")
        {
            if (host != null)
            {
                cb.Invoke(false);
            }
        }
        else
        {
            // upload php error
            Debug.LogError(www.text);
            if (host != null)
            {
                cb.Invoke(false);
            }
        }
#if UNITY_EDITOR
        Debug.Log("upload map response:" + www.text);
#endif
        cb        = null;
        isWorking = false;
    }
Ejemplo n.º 3
0
 GameObject host;// cb is valid tag, cb should is a member of MonoScript when gameobject destroy host will set-to null cb will not be call, so need host to check is valid
 public static bool UploadMap(string json, VoidFuncN <bool> cb, long file_uuid, GameObject host)
 {
     if (ins == null)
     {
         return(false);
     }
     if (string.IsNullOrEmpty(json))
     {
         return(false);
     }
     if (file_uuid < 0)
     {
         return(false);
     }
     if (cb == null)
     {
         return(false);
     }
     if (host == null)
     {
         return(false);
     }
     return(ins.AddUploadTask(json, cb, file_uuid, host));
 }