Skip to content

Commit

Permalink
Merge pull request #57 from kefniark/fix/uglyhackforandroid
Browse files Browse the repository at this point in the history
Android hack (WWW.Dispose in LongPolling)
  • Loading branch information
AlmirKadric authored Nov 25, 2016
2 parents 424f8b3 + 6563fde commit 1081b73
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions HTTPRequest/HTTPRequest.Unity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Reflection;

using UnityEngine;
using System.Threading;

namespace Wizcorp.MageSDK.Network.Http
{
Expand Down Expand Up @@ -145,21 +146,31 @@ private IEnumerator WaitLoop()
// Abort request
public void Abort()
{
if (this.request == null)
if (request == null)
{
return;
}

WWW request = this.request;
this.request = null;
DisposeWWWInBackground(request);
request = null;

request.Dispose();
timeoutTimer.Stop();
timeoutTimer = null;
}


// Create GET request and return it
// Hack : I Feel bad for that ... I'm sorry but it's the faster way we found to fix an android bug
private void DisposeWWWInBackground(WWW www)
{
#if UNITY_ANDROID
new Thread(() => {
www.Dispose();
}).Start();
#else
www.Dispose();
#endif
}

// Create GET request and return it
public static HttpRequest Get(string url, Dictionary<string, string> headers, CookieContainer cookies, Action<Exception, string> cb)
{
// Create request and return it
Expand Down

0 comments on commit 1081b73

Please sign in to comment.