Elin Decompiled Documentation EA 23.183 Nightly Patch 1
Loading...
Searching...
No Matches
Net Class Reference
Inheritance diagram for Net:

Classes

class  ChatLog
 
class  DownloadCahce
 
class  DownloadMeta
 
class  VoteLog
 

Public Member Functions

void ShowVote (string logs)
 
void ShowChat (string logs)
 

Static Public Member Functions

static async UniTask< bool > UploadFile (string id, string password, string name, string title, string path, string idLang, string cat="Home", string tag="")
 
static async UniTask< FileInfo > DownloadFile (DownloadMeta item, string path, string idLang)
 
static async UniTask< List< DownloadMeta > > GetFileList (string idLang)
 
static async UniTask< bool > SendVote (int id, string idLang)
 
static async UniTask< List< VoteLog > > GetVote (string idLang)
 
static async UniTask< bool > SendChat (string name, string msg, ChatCategory cat, string idLang)
 
static async UniTask< List< ChatLog > > GetChat (ChatCategory cat, string idLang)
 

Public Attributes

List< ChatLogchatList
 

Static Public Attributes

static string urlScript = "http://elin.cloudfree.jp/script/"
 
static string urlChat = urlScript + "chat/"
 
static string urlVote = urlScript + "vote/"
 
static string urlUpload = urlScript + "uploader/"
 
static bool isUploading
 

Properties

static bool ShowNetError [get]
 

Detailed Description

Definition at line 10 of file Net.cs.

Member Function Documentation

◆ DownloadFile()

static async UniTask< FileInfo > Net.DownloadFile ( DownloadMeta  item,
string  path,
string  idLang 
)
inlinestatic

Definition at line 164 of file Net.cs.

165 {
166 string fn = item.id + ".z";
167 DownloadCahce caches = IO.LoadFile<DownloadCahce>(CorePath.ZoneSaveUser + "cache.txt") ?? new DownloadCahce();
168 if (caches.items.TryGetValue(item.id) == item.date.Replace("\"", "") && File.Exists(path + fn))
169 {
170 Debug.Log("Returning Cache:" + path + fn);
171 return new FileInfo(path + fn);
172 }
173 using UnityWebRequest www = UnityWebRequest.Get(urlUpload + "files/" + idLang + "/" + fn);
174 www.downloadHandler = new DownloadHandlerFile(path + fn);
175 try
176 {
177 await www.SendWebRequest();
178 }
179 catch (Exception ex)
180 {
181 EClass.ui.Say(ex.Message);
182 }
183 FileInfo fileInfo = new FileInfo(path + fn);
184 if (!fileInfo.Exists || www.result != UnityWebRequest.Result.Success)
185 {
186 if (ShowNetError)
187 {
188 EClass.ui.Say(www.error);
189 }
190 return null;
191 }
192 caches.items[item.id] = item.date;
193 IO.SaveFile(CorePath.ZoneSaveUser + "cache.txt", caches);
194 return fileInfo;
195 }
static string ZoneSaveUser
Definition: CorePath.cs:198
Definition: EClass.cs:5
static UI ui
Definition: EClass.cs:16
Definition: IO.cs:11
static void SaveFile(string path, object obj, bool compress=false, JsonSerializerSettings setting=null)
Definition: IO.cs:89
static bool ShowNetError
Definition: Net.cs:76
static string urlUpload
Definition: Net.cs:71

References Debug, item, Net.DownloadCahce.items, ShowNetError, EClass.ui, urlUpload, and CorePath.ZoneSaveUser.

Referenced by TraitMoongate.UseMoongate().

◆ GetChat()

static async UniTask< List< ChatLog > > Net.GetChat ( ChatCategory  cat,
string  idLang 
)
inlinestatic

Definition at line 362 of file Net.cs.

363 {
364 List<ChatLog> list = new List<ChatLog>();
365 try
366 {
367 if (EClass.debug.enable)
368 {
369 idLang = "DEBUG";
370 }
371 string uri = string.Format(urlChat + "logs/all_{0}.json", idLang);
372 using UnityWebRequest www = UnityWebRequest.Get(uri);
373 await www.SendWebRequest();
374 if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError)
375 {
376 return null;
377 }
378 Debug.Log("Download Chat Logs: Success");
379 foreach (JToken item in (JArray)JsonConvert.DeserializeObject(www.downloadHandler.text))
380 {
381 list.Add(item.ToObject<ChatLog>());
382 }
383 foreach (ChatLog item2 in list)
384 {
385 item2.msg = item2.msg.Replace("\n", "").Replace("\r", "").Replace("&quot;", "\"")
386 .ToTitleCase();
387 }
388 list.Reverse();
389 return list;
390 }
391 catch
392 {
393 return list;
394 }
395 }
bool enable
Definition: CoreDebug.cs:285
static CoreDebug debug
Definition: EClass.cs:48
static string urlChat
Definition: Net.cs:67

References EClass.debug, Debug, CoreDebug.enable, item, Net.ChatLog.msg, and urlChat.

Referenced by LayerNewspaper.RefreshChat().

◆ GetFileList()

static async UniTask< List< DownloadMeta > > Net.GetFileList ( string  idLang)
inlinestatic

Definition at line 197 of file Net.cs.

198 {
199 List<DownloadMeta> list = new List<DownloadMeta>();
200 using UnityWebRequest www = UnityWebRequest.Get(urlUpload + "files/" + idLang + "/index.txt");
201 try
202 {
203 await www.SendWebRequest();
204 }
205 catch (Exception ex)
206 {
207 EClass.ui.Say(ex.Message);
208 }
209 if (www.result != UnityWebRequest.Result.Success)
210 {
211 if (ShowNetError)
212 {
213 EClass.ui.Say(www.error);
214 }
215 return null;
216 }
217 StringReader stringReader = new StringReader(www.downloadHandler.text);
218 for (string text = stringReader.ReadLine(); text != null; text = stringReader.ReadLine())
219 {
220 if (!string.IsNullOrEmpty(text))
221 {
222 string[] array = text.Split(',');
223 list.Add(new DownloadMeta
224 {
225 path = array[0],
226 id = Path.GetFileNameWithoutExtension(array[0]),
227 name = array[2],
228 title = array[3],
229 cat = array[5],
230 date = array[6].Replace("\"", ""),
231 version = ((array.Length >= 9) ? array[8].ToInt() : 0),
232 tag = ((array.Length >= 10) ? array[9] : "")
233 });
234 }
235 }
236 return list;
237 }
item3. title
Definition: UIBook.cs:616

References ShowNetError, title, EClass.ui, and urlUpload.

Referenced by TraitMoongate.UseMoongate().

◆ GetVote()

static async UniTask< List< VoteLog > > Net.GetVote ( string  idLang)
inlinestatic

Definition at line 267 of file Net.cs.

268 {
269 List<VoteLog> list = new List<VoteLog>();
270 try
271 {
272 string uri = string.Format(urlVote + "logs/data_{0}.txt", idLang);
273 using UnityWebRequest www = UnityWebRequest.Get(uri);
274 await www.SendWebRequest();
275 if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError)
276 {
277 if (ShowNetError)
278 {
279 EClass.ui.Say(www.error);
280 }
281 }
282 else
283 {
284 StringReader stringReader = new StringReader(www.downloadHandler.text);
285 int num = 0;
286 for (string text = stringReader.ReadLine(); text != null; text = stringReader.ReadLine())
287 {
288 string[] array = text.Split(',');
289 if (num == 0)
290 {
291 list.Add(new VoteLog
292 {
293 name = array[0].Replace("\"", ""),
294 time = array[2].ToInt(),
295 index = num
296 });
297 }
298 else
299 {
300 list.Add(new VoteLog
301 {
302 name = array[0].Replace("\"", ""),
303 count = array[1].ToInt(),
304 index = num
305 });
306 }
307 num++;
308 }
309 }
310 return list;
311 }
312 catch
313 {
314 return list;
315 }
316 }
static string urlVote
Definition: Net.cs:69

References ShowNetError, EClass.ui, and urlVote.

Referenced by LayerNewspaper.RefreshVote().

◆ SendChat()

static async UniTask< bool > Net.SendChat ( string  name,
string  msg,
ChatCategory  cat,
string  idLang 
)
inlinestatic

Definition at line 318 of file Net.cs.

319 {
321 {
322 return false;
323 }
324 try
325 {
326 if (EClass.debug.enable)
327 {
328 idLang = "DEBUG";
329 }
330 Debug.Log("Start Sending Text:");
331 WWWForm wWWForm = new WWWForm();
332 wWWForm.AddField("submit", "Send");
333 wWWForm.AddField("name", name);
334 wWWForm.AddField("msg", msg);
335 wWWForm.AddField("cat", cat.ToString());
336 wWWForm.AddField("idLang", idLang);
337 try
338 {
339 using UnityWebRequest www = UnityWebRequest.Post(urlChat + "chat.php", wWWForm);
340 await www.SendWebRequest();
341 if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError)
342 {
343 if (ShowNetError)
344 {
345 EClass.ui.Say(www.error);
346 }
347 return false;
348 }
349 Debug.Log(www.downloadHandler.text);
350 return true;
351 }
352 catch
353 {
354 }
355 }
356 catch
357 {
358 }
359 return false;
360 }
Version version
Definition: BaseCore.cs:17
static Core core
Definition: EClass.cs:6
bool demo
Definition: Version.cs:14

References EClass.core, EClass.debug, Debug, Version.demo, CoreDebug.enable, ShowNetError, EClass.ui, urlChat, and BaseCore.version.

Referenced by ActEffect.Wish().

◆ SendVote()

static async UniTask< bool > Net.SendVote ( int  id,
string  idLang 
)
inlinestatic

Definition at line 239 of file Net.cs.

240 {
241 try
242 {
243 Debug.Log("Start Sending Vote:");
244 WWWForm wWWForm = new WWWForm();
245 wWWForm.AddField("vote", id.ToString() ?? "");
246 wWWForm.AddField("idLang", idLang);
247 wWWForm.AddField("submit", "Send");
248 using UnityWebRequest www = UnityWebRequest.Post(urlVote + "vote.php", wWWForm);
249 await www.SendWebRequest();
250 if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError)
251 {
252 if (ShowNetError)
253 {
254 EClass.ui.Say(www.error);
255 }
256 return false;
257 }
258 Debug.Log(www.downloadHandler.text);
259 return true;
260 }
261 catch
262 {
263 return true;
264 }
265 }

References Debug, ShowNetError, EClass.ui, and urlVote.

Referenced by LayerNewspaper.RefreshVote().

◆ ShowChat()

void Net.ShowChat ( string  logs)
inline

Definition at line 96 of file Net.cs.

97 {
98 foreach (JToken item in (JArray)JsonConvert.DeserializeObject(logs))
99 {
100 ChatLog chatLog = item.ToObject<ChatLog>();
101 Debug.Log(chatLog.name + "/" + chatLog.msg);
102 }
103 }

References Debug, item, Net.ChatLog.msg, and Net.ChatLog.name.

◆ ShowVote()

void Net.ShowVote ( string  logs)
inline

Definition at line 87 of file Net.cs.

88 {
89 StringReader stringReader = new StringReader(logs);
90 for (string text = stringReader.ReadLine(); text != null; text = stringReader.ReadLine())
91 {
92 Debug.Log(text);
93 }
94 }

References Debug.

◆ UploadFile()

static async UniTask< bool > Net.UploadFile ( string  id,
string  password,
string  name,
string  title,
string  path,
string  idLang,
string  cat = "Home",
string  tag = "" 
)
inlinestatic

Definition at line 105 of file Net.cs.

106 {
107 if (isUploading)
108 {
109 EClass.ui.Say("sys_uploadUploading");
110 return false;
111 }
112 EClass.ui.Say("sys_uploadStart");
113 byte[] array;
114 using (FileStream fileStream = File.OpenRead(path))
115 {
116 array = new byte[fileStream.Length];
117 fileStream.Read(array, 0, (int)fileStream.Length);
118 }
119 WWWForm wWWForm = new WWWForm();
120 wWWForm.AddField("mode", 1);
121 wWWForm.AddField("id", id);
122 wWWForm.AddField("name", name);
123 wWWForm.AddField("title", title);
124 wWWForm.AddField("cat", cat);
125 wWWForm.AddField("tag", tag);
126 wWWForm.AddField("idLang", idLang);
127 wWWForm.AddField("password", password);
128 wWWForm.AddField("submit", "Send");
129 wWWForm.AddField("version", EClass.core.version.GetInt().ToString() ?? "");
130 wWWForm.AddBinaryData("file", array, "file.z");
131 isUploading = true;
132 Debug.Log(id);
133 Debug.Log(name);
134 Debug.Log(title);
135 Debug.Log(idLang);
136 Debug.Log(password);
137 Debug.Log(tag);
138 Debug.Log(array.Length);
139 using (UnityWebRequest www = UnityWebRequest.Post(urlUpload + "uploader.php", wWWForm))
140 {
141 try
142 {
143 await www.SendWebRequest();
144 Debug.Log(www.result.ToString());
145 Debug.Log(www.downloadHandler.ToString());
146 Debug.Log(www.downloadHandler.text);
147 Debug.Log(www.downloadHandler.text.ToString());
148 }
149 catch (Exception ex)
150 {
151 EClass.ui.Say(ex.Message);
152 }
153 isUploading = false;
154 if (www.result != UnityWebRequest.Result.Success)
155 {
156 EClass.ui.Say((www.responseCode == 401) ? "sys_uploadConflict" : "sys_uploadFail");
157 return false;
158 }
159 }
160 EClass.ui.Say("sys_uploadSuccess");
161 return true;
162 }
static bool isUploading
Definition: Net.cs:73
int GetInt()
Definition: Version.cs:21

References EClass.core, Debug, Version.GetInt(), isUploading, title, EClass.ui, urlUpload, and BaseCore.version.

Referenced by LayerUploader.Upload().

Member Data Documentation

◆ chatList

List<ChatLog> Net.chatList

Definition at line 63 of file Net.cs.

◆ isUploading

bool Net.isUploading
static

Definition at line 73 of file Net.cs.

Referenced by UploadFile().

◆ urlChat

string Net.urlChat = urlScript + "chat/"
static

Definition at line 67 of file Net.cs.

Referenced by GetChat(), and SendChat().

◆ urlScript

string Net.urlScript = "http://elin.cloudfree.jp/script/"
static

Definition at line 65 of file Net.cs.

◆ urlUpload

string Net.urlUpload = urlScript + "uploader/"
static

Definition at line 71 of file Net.cs.

Referenced by DownloadFile(), GetFileList(), and UploadFile().

◆ urlVote

string Net.urlVote = urlScript + "vote/"
static

Definition at line 69 of file Net.cs.

Referenced by GetVote(), and SendVote().

Property Documentation

◆ ShowNetError

bool Net.ShowNetError
staticget

Definition at line 75 of file Net.cs.

76 {
77 get
78 {
80 {
81 return EClass.debug.enable;
82 }
83 return true;
84 }
85 }
CoreConfig config
Definition: Core.cs:70

Referenced by DownloadFile(), GetFileList(), GetVote(), SendChat(), and SendVote().


The documentation for this class was generated from the following file: