Skip to content

Commit 1081b73

Browse files
authored
Merge pull request #57 from kefniark/fix/uglyhackforandroid
Android hack (WWW.Dispose in LongPolling)
2 parents 424f8b3 + 6563fde commit 1081b73

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

HTTPRequest/HTTPRequest.Unity.cs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System.Reflection;
1212

1313
using UnityEngine;
14+
using System.Threading;
1415

1516
namespace Wizcorp.MageSDK.Network.Http
1617
{
@@ -145,21 +146,31 @@ private IEnumerator WaitLoop()
145146
// Abort request
146147
public void Abort()
147148
{
148-
if (this.request == null)
149+
if (request == null)
149150
{
150151
return;
151152
}
152153

153-
WWW request = this.request;
154-
this.request = null;
154+
DisposeWWWInBackground(request);
155+
request = null;
155156

156-
request.Dispose();
157157
timeoutTimer.Stop();
158158
timeoutTimer = null;
159159
}
160160

161-
162-
// Create GET request and return it
161+
// Hack : I Feel bad for that ... I'm sorry but it's the faster way we found to fix an android bug
162+
private void DisposeWWWInBackground(WWW www)
163+
{
164+
#if UNITY_ANDROID
165+
new Thread(() => {
166+
www.Dispose();
167+
}).Start();
168+
#else
169+
www.Dispose();
170+
#endif
171+
}
172+
173+
// Create GET request and return it
163174
public static HttpRequest Get(string url, Dictionary<string, string> headers, CookieContainer cookies, Action<Exception, string> cb)
164175
{
165176
// Create request and return it

0 commit comments

Comments
 (0)