You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

53 lines
1.3 KiB

  1. using System.Collections.Generic;
  2. using UnityEditor;
  3. using UnityEngine.Networking;
  4. namespace UnityEngine.UDP.Editor.Analytics
  5. {
  6. public static class WebRequestQueue
  7. {
  8. static Queue<EditorAnalyticsReqStruct> requestQueue = new Queue<EditorAnalyticsReqStruct>();
  9. private static bool attachedDelegate = false;
  10. public static void WebRequestUpdate()
  11. {
  12. if (requestQueue.Count == 0)
  13. {
  14. return;
  15. }
  16. EditorAnalyticsReqStruct reqStruct = requestQueue.Dequeue();
  17. UnityWebRequest request = reqStruct.webRequest;
  18. if (request != null && request.isDone)
  19. {
  20. if (request.error != null || request.responseCode / 100 != 2)
  21. {
  22. }
  23. else
  24. {
  25. }
  26. }
  27. else
  28. {
  29. requestQueue.Enqueue(reqStruct);
  30. }
  31. }
  32. internal static void Enqueue(EditorAnalyticsReqStruct request)
  33. {
  34. if (!attachedDelegate)
  35. {
  36. EditorApplication.update += WebRequestUpdate;
  37. }
  38. requestQueue.Enqueue(request);
  39. }
  40. }
  41. struct EditorAnalyticsReqStruct
  42. {
  43. public string eventName;
  44. public UnityWebRequest webRequest;
  45. }
  46. }