remove unused corutines in webmanager
This commit is contained in:
@@ -76,195 +76,6 @@ namespace UVC.Networks
|
||||
_webConfigLoader.LoadFromJsonString(json);
|
||||
}
|
||||
|
||||
//Post동작을 실행하는 함수입니다
|
||||
public void Request_Post(object inputclass, string type, System.Action<bool, string> ResultCallback)
|
||||
{
|
||||
//입력된 클래스를 json데이터로 변환합니다.
|
||||
string json = JsonConvert.SerializeObject(inputclass);
|
||||
StartCoroutine(Web_Post(_webConfigLoader.BaseUrl + type, json, (result, text) =>
|
||||
{
|
||||
ResultCallback(result, text);
|
||||
}));
|
||||
}
|
||||
|
||||
//Get동작을 실행하는 함수입니다.
|
||||
public void Request_Get(string type, System.Action<bool, string> ResultCallback)
|
||||
{
|
||||
StartCoroutine(Web_Get(_webConfigLoader.BaseUrl + type, (result, text) =>
|
||||
{
|
||||
ResultCallback(result, text);
|
||||
}));
|
||||
}
|
||||
|
||||
//Put동작을 실행하는 함수입니다.
|
||||
public void Request_Put(string type, System.Action<bool, string> ResultCallback)
|
||||
{
|
||||
StartCoroutine(Web_Put(_webConfigLoader.BaseUrl + type, (result, text) =>
|
||||
{
|
||||
ResultCallback(result, text);
|
||||
}));
|
||||
}
|
||||
|
||||
public void Request_Put(object inputclass, string type, System.Action<bool, string> ResultCallback)
|
||||
{
|
||||
string json = JsonConvert.SerializeObject(inputclass);
|
||||
StartCoroutine(Web_Put(_webConfigLoader.BaseUrl + type, json, (result, text) =>
|
||||
{
|
||||
ResultCallback(result, text);
|
||||
}));
|
||||
}
|
||||
|
||||
IEnumerator Web_Post(string URL, string json, System.Action<bool, string> callback)
|
||||
{
|
||||
using (UnityWebRequest request = UnityWebRequest.PostWwwForm(URL, json))
|
||||
{
|
||||
byte[] jsonToSend = new System.Text.UTF8Encoding().GetBytes(json);
|
||||
|
||||
request.uploadHandler.Dispose();
|
||||
request.uploadHandler = new UploadHandlerRaw(jsonToSend);
|
||||
request.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
|
||||
request.SetRequestHeader("Content-Type", "application/json");
|
||||
request.SetRequestHeader("Authorization", "Bearer " + _webConfigLoader.Token);
|
||||
|
||||
yield return request.SendWebRequest();
|
||||
Debug.Log(URL);
|
||||
Debug.Log(json);
|
||||
|
||||
//result가 에러로 왔다면
|
||||
if ((request.result == UnityWebRequest.Result.ConnectionError) || (request.result == UnityWebRequest.Result.ProtocolError))
|
||||
{
|
||||
Debug.Log(request.error);
|
||||
//callback을 false로 하고 텍스트를 리턴합니다.
|
||||
callback(false, request.downloadHandler.text);
|
||||
}
|
||||
else
|
||||
{
|
||||
//result가 에러가 아니라면, callback을 true로 하고 텍스트를 리턴합니다.
|
||||
Debug.Log(request.downloadHandler.text);
|
||||
callback(true, request.downloadHandler.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator Web_Get(string URL, System.Action<bool, string> callback)
|
||||
{
|
||||
using (UnityWebRequest request = UnityWebRequest.Get(URL))
|
||||
{
|
||||
request.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
|
||||
request.SetRequestHeader("Authorization", "Bearer " + _webConfigLoader.Token);
|
||||
|
||||
|
||||
yield return request.SendWebRequest();
|
||||
|
||||
//result가 에러로 왔다면
|
||||
if ((request.result == UnityWebRequest.Result.ConnectionError) || (request.result == UnityWebRequest.Result.ProtocolError))
|
||||
{
|
||||
Debug.Log(request.error);
|
||||
//callback을 false로 하고 텍스트를 리턴합니다.
|
||||
callback(false, request.downloadHandler.text);
|
||||
}
|
||||
else
|
||||
{
|
||||
//result가 에러가 아니라면, callback을 true로 하고 텍스트를 리턴합니다.
|
||||
Debug.Log(request.downloadHandler.text);
|
||||
callback(true, request.downloadHandler.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator Web_Put(string URL, System.Action<bool, string> callback)
|
||||
{
|
||||
byte[] data = { };
|
||||
using (UnityWebRequest request = UnityWebRequest.Put(URL, data))
|
||||
{
|
||||
request.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
|
||||
request.SetRequestHeader("Authorization", "Bearer " + _webConfigLoader.Token);
|
||||
|
||||
|
||||
yield return request.SendWebRequest();
|
||||
|
||||
//result가 에러로 왔다면
|
||||
if ((request.result == UnityWebRequest.Result.ConnectionError) || (request.result == UnityWebRequest.Result.ProtocolError))
|
||||
{
|
||||
Debug.Log(request.error);
|
||||
//callback을 false로 하고 텍스트를 리턴합니다.
|
||||
callback(false, request.downloadHandler.text);
|
||||
}
|
||||
else
|
||||
{
|
||||
//result가 에러가 아니라면, callback을 true로 하고 텍스트를 리턴합니다.
|
||||
Debug.Log(request.downloadHandler.text);
|
||||
callback(true, request.downloadHandler.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator Web_Put(string URL, string json, System.Action<bool, string> callback)
|
||||
{
|
||||
byte[] data = { };
|
||||
using (UnityWebRequest request = UnityWebRequest.Put(URL, data))
|
||||
{
|
||||
byte[] jsonToSend = new System.Text.UTF8Encoding().GetBytes(json);
|
||||
|
||||
request.uploadHandler.Dispose();
|
||||
request.uploadHandler = new UploadHandlerRaw(jsonToSend);
|
||||
request.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
|
||||
request.SetRequestHeader("Content-Type", "application/json");
|
||||
request.SetRequestHeader("Authorization", "Bearer " + _webConfigLoader.Token);
|
||||
|
||||
yield return request.SendWebRequest();
|
||||
|
||||
//result가 에러로 왔다면
|
||||
if ((request.result == UnityWebRequest.Result.ConnectionError) || (request.result == UnityWebRequest.Result.ProtocolError))
|
||||
{
|
||||
Debug.Log(request.error);
|
||||
//callback을 false로 하고 텍스트를 리턴합니다.
|
||||
callback(false, request.downloadHandler.text);
|
||||
}
|
||||
else
|
||||
{
|
||||
//result가 에러가 아니라면, callback을 true로 하고 텍스트를 리턴합니다.
|
||||
Debug.Log(request.downloadHandler.text);
|
||||
callback(true, request.downloadHandler.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
//별도의 Data Content 가 없을 경우 reqeustURL 과 callback 등 만을 parameter로 넘기면 됨
|
||||
//public void Reqeust_Get<T>(string requestURL, Action<T> callback, string json = "")
|
||||
//{
|
||||
// RequestAsync<T>(requestURL, RequestType.GET, json)
|
||||
// .ContinueWith(result => callback?.Invoke(result))
|
||||
// .Forget();
|
||||
//}
|
||||
|
||||
//public void Reqeust_Post<T>(string requestURL, Action<T> callback, string json = "")
|
||||
//{
|
||||
// RequestAsync<T>(requestURL, RequestType.POST, json)
|
||||
// .ContinueWith(result => callback?.Invoke(result))
|
||||
// .Forget();
|
||||
//}
|
||||
|
||||
//public void Reqeust_Put<T>(string requestURL, Action<T> callback, string json = "")
|
||||
//{
|
||||
// RequestAsync<T>(requestURL, RequestType.PUT, json)
|
||||
// .ContinueWith(result => callback?.Invoke(result))
|
||||
// .Forget();
|
||||
//}
|
||||
|
||||
//public void Reqeust_Patch<T>(string requestURL, Action<T> callback, string json = "")
|
||||
//{
|
||||
// RequestAsync<T>(requestURL, RequestType.PATCH, json)
|
||||
// .ContinueWith(result => callback?.Invoke(result))
|
||||
// .Forget();
|
||||
//}
|
||||
|
||||
//public void Reqeust_Delete<T>(string requestURL, Action<T> callback, string json = "")
|
||||
//{
|
||||
// RequestAsync<T>(requestURL, RequestType.DELETE, json)
|
||||
// .ContinueWith(result => callback?.Invoke(result))
|
||||
// .Forget();
|
||||
//}
|
||||
|
||||
//별도의 Data Content 가 없을 경우 reqeustURL 과 callback 등 만을 parameter로 넘기면 됨
|
||||
public void Reqeust<T>(string requestURL, RequestType type , Action<T> callback, object json = null)
|
||||
{
|
||||
@@ -285,9 +96,6 @@ namespace UVC.Networks
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private async UniTask<T> RequestAsync<T>(string requestURL, RequestType type, string json = "")
|
||||
{
|
||||
string fullUrl = _webConfigLoader.BaseUrl + requestURL;
|
||||
@@ -319,8 +127,6 @@ namespace UVC.Networks
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private bool IsSuccess(UnityWebRequest.Result result)
|
||||
{
|
||||
switch(result)
|
||||
|
||||
Reference in New Issue
Block a user