forked from andyburke/UnityHTTP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResponseCallbackDispatcher.cs
More file actions
50 lines (43 loc) · 1.29 KB
/
ResponseCallbackDispatcher.cs
File metadata and controls
50 lines (43 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using UnityEngine;
using System;
using System.Collections;
namespace HTTP
{
public class ResponseCallbackDispatcher : MonoBehaviour
{
private static ResponseCallbackDispatcher singleton = null;
private static GameObject singletonGameObject = null;
private static object singletonLock = new object();
public static ResponseCallbackDispatcher Singleton {
get {
return singleton;
}
}
public Queue requests = Queue.Synchronized( new Queue() );
public static void Init()
{
if ( singleton != null )
{
return;
}
lock( singletonLock )
{
if ( singleton != null )
{
return;
}
singletonGameObject = new GameObject();
singleton = singletonGameObject.AddComponent< ResponseCallbackDispatcher >();
singletonGameObject.name = "HTTPResponseCallbackDispatcher";
}
}
public void Update()
{
while( requests.Count > 0 )
{
HTTP.Request request = (Request)requests.Dequeue();
request.completedCallback( request );
}
}
}
}