void ServerStart() { SimpleWebServer.Start(_port); _statusMessage = "Server Running"; UpdateHosts(); if (_activeHost == null) { ActiveHost = _hosts[0]; } SimpleWebServer.ServerURL = ActiveHost; }
public override bool Update() { if (decryptedLoadOperation != null) { decryptedLoadOperation.Update(); if (decryptedLoadOperation.IsDone()) { assetBundle = decryptedLoadOperation.assetBundle; downloadProgress = 1f; m_WWW.Dispose(); m_WWW = null; return(false); } else //keep updating { downloadProgress = 0.9f + (decryptedLoadOperation.progress / 100); return(true); } } else { base.Update(); } // TODO: When can check iOS copy this into the iOS functions above // This checks that the download is actually happening and restarts it if it is not //fixes a bug in SimpleWebServer where it would randomly stop working for some reason if (!downloadIsDone) { downloadProgress = m_WWW.progress; if (!string.IsNullOrEmpty(m_WWW.error)) { Debug.Log("[AssetBundleLoadOperation] download error for " + m_WWW.url + " : " + m_WWW.error); } else { if (m_WWW.progress == 0) { zeroDownload++; } #if UNITY_EDITOR //Sometimes SimpleWebServer randomly looses it port connection //Sometimes restarting the download helps, sometimes it needs to be completely restarted if (SimpleWebServer.Instance != null) { if (zeroDownload == 150) { Debug.Log("[AssetBundleLoadOperation] progress was zero for 150 frames restarting dowload"); m_WWW.Dispose(); //sometimes makes a difference when the download fails m_WWW = null; m_WWW = new WWW(m_Url); } if (zeroDownload == 300) //If we are in the editor we can restart the Server and this will make it work { Debug.LogWarning("[AssetBundleLoadOperation] progress was zero for 300 frames restarting the server"); //we wont be able to do the following from a build int port = SimpleWebServer.Instance.Port; SimpleWebServer.Start(port); m_WWW.Dispose(); m_WWW = null; m_WWW = new WWW(m_Url); zeroDownload = 0; } } else #endif if (zeroDownload == 500) { Debug.Log("[AssetBundleLoadOperation] progress was zero for 500 frames restarting dowload"); m_WWW.Dispose(); m_WWW = null; m_WWW = new WWW(m_Url); zeroDownload = 0; } } return(true); } else { downloadProgress = 1f; return(false); } }