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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
using System;
using System.Collections;
using System.IO;
using System.Threading;
using UnityEngine;
using XUtliPoolLib;
namespace XUpdater
{
internal sealed class XVersion : MonoBehaviour
{
public static string VERSION_FILE
{
get
{
return string.Format("manifest.{0}.assetbundle", XSingleton<XUpdater>.singleton.TargetVersion.ToString());
}
}
public static readonly string LOCAL_VERSION_FILE = "manifest.asset";
private WWW _server_Version = null;
private uint _time_out_token = 0u;
private delegate void HandleFinishDownload(WWW www, string error);
public static string GetLocalVersion()
{
return XSingleton<XCaching>.singleton.UpdatePath + XVersion.LOCAL_VERSION_FILE;
}
public void ServerDownload(HandleVersionDownload callback1, HandleVersionLoaded callback2)
{
base.StopAllCoroutines();
string text = XSingleton<XCaching>.singleton.HostUrl + XSingleton<XUpdater>.singleton.Platform;
XSingleton<XLoadingUI>.singleton.SetStatus(XSingleton<XStringTable>.singleton.GetString("XUPDATE_INFO_CONNECTING"), byte.MaxValue, byte.MaxValue, byte.MaxValue);
XSingleton<XDebug>.singleton.AddLog("connecting to update server: ", text, null, null, null, null, XDebugColor.XDebug_None);
this._time_out_token = XSingleton<XTimerMgr>.singleton.SetTimer(5f, new XTimerMgr.ElapsedEventHandler(this.OnTimeOut), null);
base.StartCoroutine(this.DownloadVersion(XSingleton<XCaching>.singleton.MakeToken(text + XVersion.VERSION_FILE), callback1, callback2));
}
private IEnumerator DownloadVersion(string url, HandleVersionDownload callback1, HandleVersionLoaded callback2)
{
this._server_Version = new WWW(url);
yield return this._server_Version;
XSingleton<XLoadingUI>.singleton.SetStatus(XSingleton<XStringTable>.singleton.GetString("XUPDATE_INFO_CHECKUPDATING"), byte.MaxValue, byte.MaxValue, byte.MaxValue);
XSingleton<XTimerMgr>.singleton.KillTimer(this._time_out_token);
bool flag = this._server_Version != null;
if (flag)
{
bool flag2 = string.IsNullOrEmpty(this._server_Version.error);
if (flag2)
{
bool flag3 = callback1 != null;
if (flag3)
{
AssetBundle ab = this._server_Version.assetBundle;
bool flag4 = ab == null;
if (flag4)
{
XSingleton<XDebug>.singleton.AddErrorLog("load server manifest bundle error.", null, null, null, null, null);
XSingleton<XLoadingUI>.singleton.SetStatus(XSingleton<XStringTable>.singleton.GetString("XUPDATE_ERROR_FETCHMANIFESTERROR"), byte.MaxValue, byte.MaxValue, byte.MaxValue);
XSingleton<XUpdater>.singleton.OnError();
}
else
{
UnityEngine.Object asset = ab.LoadAsset("manifest", typeof(TextAsset));
bool flag5 = asset == null;
if (flag5)
{
XSingleton<XDebug>.singleton.AddErrorLog("load server manifest bundle error.", null, null, null, null, null);
XSingleton<XLoadingUI>.singleton.SetStatus(XSingleton<XStringTable>.singleton.GetString("XUPDATE_ERROR_FETCHMANIFESTERROR"), byte.MaxValue, byte.MaxValue, byte.MaxValue);
XSingleton<XUpdater>.singleton.OnError();
}
else
{
AsyncVersionProcessRequest avpr = callback1(asset as TextAsset);
while (!avpr.IsDone)
{
Thread.Sleep(1);
}
bool flag6 = callback2 != null;
if (flag6)
{
callback2(avpr.IsCorrect);
}
ab.Unload(false);
avpr = null;
}
asset = null;
}
ab = null;
}
}
else
{
bool flag7 = XUpdater.LaunchMode == XLaunchMode.Dev;
if (flag7)
{
XSingleton<XUpdater>.singleton.DevStart();
}
else
{
XSingleton<XDebug>.singleton.AddErrorLog(this._server_Version.error, null, null, null, null, null);
XSingleton<XLoadingUI>.singleton.SetStatus(XSingleton<XStringTable>.singleton.GetString("XUPDATE_ERROR_FETCHMANIFESTERROR"), byte.MaxValue, byte.MaxValue, byte.MaxValue);
XSingleton<XUpdater>.singleton.OnError();
}
}
this._server_Version.Dispose();
this._server_Version = null;
}
else
{
XSingleton<XDebug>.singleton.AddErrorLog("ERROR: _server_Version is NULL!", null, null, null, null, null);
XSingleton<XLoadingUI>.singleton.SetStatus(XSingleton<XStringTable>.singleton.GetString("XUPDATE_ERROR_FETCHMANIFESTERROR"), byte.MaxValue, byte.MaxValue, byte.MaxValue);
XSingleton<XUpdater>.singleton.OnError();
}
yield break;
}
private IEnumerator LocalDownload(XVersion.HandleFinishDownload callback)
{
string path = Application.persistentDataPath + XVersion.VERSION_FILE;
bool flag = !File.Exists(path);
if (flag)
{
bool flag2 = callback != null;
if (flag2)
{
callback(null, null);
}
}
else
{
string local_location = "file://" + path;
WWW localVersion = new WWW(local_location);
yield return localVersion;
bool flag3 = callback != null;
if (flag3)
{
callback(localVersion, localVersion.error);
}
localVersion.Dispose();
localVersion = null;
local_location = null;
localVersion = null;
}
yield break;
}
private void OnTimeOut(object o)
{
bool flag = XUpdater.LaunchMode == XLaunchMode.Dev;
if (flag)
{
XSingleton<XUpdater>.singleton.DevStart();
bool flag2 = (int)Application.platform == 7 || Application.platform == 0;
if (flag2)
{
XSingleton<XDebug>.singleton.AddErrorLog("Connect to update server timeout...", null, null, null, null, null);
}
}
else
{
XSingleton<XLoadingUI>.singleton.SetStatus(XSingleton<XStringTable>.singleton.GetString("XUPDATE_ERROR_CANNOTCONNECTTOSERVER"), byte.MaxValue, byte.MaxValue, byte.MaxValue);
XSingleton<XUpdater>.singleton.OnError();
}
base.StopAllCoroutines();
this._server_Version.Dispose();
this._server_Version = null;
}
}
}
|