/// <summary> /// 分配一个实例空间,并开启请求 /// </summary> /// <param name="url"></param> /// <param name="postDataDic"></param> /// <param name="headers"></param> /// <param name="callback"></param> /// <param name="progress"></param> /// <param name="args"></param> public static void Post(string url, Dictionary <string, string> postDataDic, Dictionary <string, string> headers = null, Action <string, long, object[]> callback = null, Action <float> progress = null, params object[] args) { if (NetEventTmpSave.HasEventNone(NetEventTmpSave.EventType.POST, url)) { NetEventTmpSave.AddEvent(NetEventTmpSave.EventType.POST, url, callback); } else { NetEventTmpSave.AddEvent(NetEventTmpSave.EventType.POST, url, callback); Action <string, long, object[]> callbackt = (uurl, code, aargs) => { NetEventTmpSave.Invoke(NetEventTmpSave.EventType.POST, uurl, code, aargs); }; NetPostRequest request = NetPostRequest.Allocate(url, postDataDic, headers, callbackt, progress, args); Instance.StartCoroutine(request.IEnumStart()); } }
/// <summary> /// DELETE 返回字符串 /// </summary> /// <param name="url"></param> /// <param name="headers"></param> /// <param name="callbackStr"></param> /// <param name="progress"></param> public static void DeleteString(string url, Dictionary <string, string> headers = null, Action <string, long, string, object[]> callbackStr = null, Action <float> progress = null, params object[] args) { if (NetEventTmpSave.HasEventStr(NetEventTmpSave.EventType.DELETE, url)) { NetEventTmpSave.AddEvent(NetEventTmpSave.EventType.DELETE, url, callbackStr); } else { NetEventTmpSave.AddEvent(NetEventTmpSave.EventType.DELETE, url, callbackStr); Action <string, long, string, object[]> callback = (uurl, code, content, aargs) => { NetEventTmpSave.Invoke(NetEventTmpSave.EventType.DELETE, uurl, code, content, aargs); }; NetDeleteRequest request = NetDeleteRequest.Allocate(url, headers, callback, progress, args); Instance.StartCoroutine(request.IEnumStart()); } }
/// <summary> /// GET Bytearr /// </summary> /// <param name="url"></param> /// <param name="filter"></param> /// <param name="headers"></param> /// <param name="callbackBs"></param> /// <param name="progress"></param> /// <param name="args"></param> public static void GetByteArr(string url, Dictionary <string, string> filter = null, Dictionary <string, string> headers = null, Action <string, long, byte[], object[]> callbackBs = null, Action <float> progress = null, params object[] args) { if (NetEventTmpSave.HasEventByteArr(NetEventTmpSave.EventType.GET, url)) { NetEventTmpSave.AddEvent(NetEventTmpSave.EventType.GET, url, callbackBs); } else { NetEventTmpSave.AddEvent(NetEventTmpSave.EventType.GET, url, callbackBs); Action <string, long, byte[], object[]> callback = (uurl, code, bs, aargs) => { NetEventTmpSave.Invoke(NetEventTmpSave.EventType.GET, uurl, code, bs, aargs); }; NetGetRequest request = NetGetRequest.Allocate(url, filter, headers, callback, progress, args); Instance.StartCoroutine(request.IEnumStart()); } }