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

Classes

class  BookData
 
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)
 
static async UniTask< bool > SendBook (string name, string msg, BookCategory cat, string idLang, string msg2, string msg3, string msg4)
 
static async UniTask< List< BookData > > GetBook (BookCategory cat, string idLang)
 

Public Attributes

List< ChatLogchatList
 

Static Public Attributes

static string urlScript = "http://elin.cloudfree.jp/script/"
 
static string urlBook = urlScript + "book/"
 
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 11 of file Net.cs.

Member Function Documentation

◆ DownloadFile()

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

Definition at line 180 of file Net.cs.

181 {
182 string path2 = item.id + ".z";
183 string fullPath = path + path2.SanitizeFileName();
184 DownloadCahce caches = IO.LoadFile<DownloadCahce>(CorePath.ZoneSaveUser + "cache.txt") ?? new DownloadCahce();
185 if (caches.items.TryGetValue(item.id) == item.date.Replace("\"", "") && File.Exists(fullPath))
186 {
187 Debug.Log("Returning Cache:" + fullPath);
188 return new FileInfo(fullPath);
189 }
190 using UnityWebRequest www = UnityWebRequest.Get(urlUpload + item.path);
191 www.downloadHandler = new DownloadHandlerFile(fullPath);
192 try
193 {
194 await www.SendWebRequest();
195 }
196 catch (Exception ex)
197 {
198 EClass.ui.Say(ex.Message);
199 }
200 FileInfo fileInfo = new FileInfo(fullPath);
201 if (!fileInfo.Exists || www.result != UnityWebRequest.Result.Success)
202 {
203 if (ShowNetError)
204 {
205 EClass.ui.Say(www.error);
206 }
207 return null;
208 }
209 caches.items[item.id] = item.date;
210 IO.SaveFile(CorePath.ZoneSaveUser + "cache.txt", caches);
211 return fileInfo;
212 }
static string ZoneSaveUser
Definition: CorePath.cs:194
Definition: EClass.cs:6
static UI ui
Definition: EClass.cs:17
Definition: IO.cs:10
static void SaveFile(string path, object obj, bool compress=false, JsonSerializerSettings setting=null)
Definition: IO.cs:88

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

◆ GetBook()

static async UniTask< List< BookData > > Net.GetBook ( BookCategory  cat,
string  idLang 
)
inlinestatic

Definition at line 465 of file Net.cs.

466 {
467 List<BookData> list = new List<BookData>();
468 try
469 {
470 if (EClass.debug.enable)
471 {
472 idLang = "DEBUG";
473 }
474 string uri = string.Format(urlBook + "logs/all_{0}.json", idLang);
475 using UnityWebRequest www = UnityWebRequest.Get(uri);
476 await www.SendWebRequest();
477 if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError)
478 {
479 return null;
480 }
481 Debug.Log("Download Book: Success");
482 foreach (JToken item in (JArray)JsonConvert.DeserializeObject(www.downloadHandler.text))
483 {
484 list.Add(item.ToObject<BookData>());
485 }
486 foreach (BookData item2 in list)
487 {
488 item2.msg = item2.msg.Replace("\n", "").Replace("\r", "").Replace("&quot;", "\"")
489 .ToTitleCase();
490 }
491 list.Reverse();
492 return list;
493 }
494 catch
495 {
496 return list;
497 }
498 }
bool enable
Definition: CoreDebug.cs:301
static CoreDebug debug
Definition: EClass.cs:49

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

◆ GetChat()

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

Definition at line 383 of file Net.cs.

384 {
385 List<ChatLog> list = new List<ChatLog>();
386 try
387 {
388 if (EClass.debug.enable)
389 {
390 idLang = "DEBUG";
391 }
392 string uri = string.Format(urlChat + "logs/all_{0}.json", idLang);
393 using UnityWebRequest www = UnityWebRequest.Get(uri);
394 await www.SendWebRequest();
395 if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError)
396 {
397 return null;
398 }
399 Debug.Log("Download Chat Logs: Success");
400 foreach (JToken item in (JArray)JsonConvert.DeserializeObject(www.downloadHandler.text))
401 {
402 list.Add(item.ToObject<ChatLog>());
403 }
404 foreach (ChatLog item2 in list)
405 {
406 item2.msg = item2.msg.Replace("\n", "").Replace("\r", "").Replace("&quot;", "\"")
407 .ToTitleCase();
408 }
409 list.Reverse();
410 return list;
411 }
412 catch
413 {
414 return list;
415 }
416 }

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

◆ GetFileList()

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

Definition at line 214 of file Net.cs.

215 {
216 List<DownloadMeta> list = new List<DownloadMeta>();
217 using UnityWebRequest www = UnityWebRequest.Get(urlUpload + "files/" + idLang + "/index.txt");
218 try
219 {
220 await www.SendWebRequest();
221 }
222 catch (Exception ex)
223 {
224 EClass.ui.Say(ex.Message);
225 }
226 if (www.result != UnityWebRequest.Result.Success)
227 {
228 if (ShowNetError)
229 {
230 EClass.ui.Say(www.error);
231 }
232 return null;
233 }
234 string[] array = www.downloadHandler.text.SplitNewline();
235 foreach (string obj in array)
236 {
237 string[] array2 = obj.Split(',');
238 if (obj.StartsWith("files") && array2.Length >= 7)
239 {
240 list.Add(new DownloadMeta
241 {
242 path = array2[0],
243 id = WebUtility.HtmlDecode(array2[1]),
244 name = WebUtility.HtmlDecode(array2[2]),
245 title = WebUtility.HtmlDecode(array2[3]),
246 cat = array2[5],
247 date = array2[6].Replace("\"", ""),
248 version = ((array2.Length > 8) ? array2[8].ToInt() : 0),
249 tag = ((array2.Length > 9) ? array2[9] : "")
250 });
251 }
252 }
253 return list;
254 }
item3. title
Definition: UIBook.cs:640

References ShowNetError, title, and EClass.ui.

◆ GetVote()

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

Definition at line 284 of file Net.cs.

285 {
286 List<VoteLog> list = new List<VoteLog>();
287 try
288 {
289 string uri = string.Format(urlVote + "logs/data_{0}.txt", idLang);
290 using UnityWebRequest www = UnityWebRequest.Get(uri);
291 await www.SendWebRequest();
292 if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError)
293 {
294 if (ShowNetError)
295 {
296 EClass.ui.Say(www.error);
297 }
298 }
299 else
300 {
301 StringReader stringReader = new StringReader(www.downloadHandler.text);
302 int num = 0;
303 for (string text = stringReader.ReadLine(); text != null; text = stringReader.ReadLine())
304 {
305 string[] array = text.Split(',');
306 if (num == 0)
307 {
308 list.Add(new VoteLog
309 {
310 name = array[0].Replace("\"", ""),
311 time = array[2].ToInt(),
312 index = num
313 });
314 }
315 else
316 {
317 list.Add(new VoteLog
318 {
319 name = array[0].Replace("\"", ""),
320 count = array[1].ToInt(),
321 index = num
322 });
323 }
324 num++;
325 }
326 }
327 return list;
328 }
329 catch
330 {
331 return list;
332 }
333 }

References ShowNetError, and EClass.ui.

◆ SendBook()

static async UniTask< bool > Net.SendBook ( string  name,
string  msg,
BookCategory  cat,
string  idLang,
string  msg2,
string  msg3,
string  msg4 
)
inlinestatic

Definition at line 418 of file Net.cs.

419 {
421 {
422 return false;
423 }
424 try
425 {
426 if (EClass.debug.enable)
427 {
428 idLang = "DEBUG";
429 }
430 Debug.Log("Start Sending Book:");
431 WWWForm wWWForm = new WWWForm();
432 wWWForm.AddField("submit", "Send");
433 wWWForm.AddField("name", name);
434 wWWForm.AddField("msg", msg);
435 wWWForm.AddField("cat", cat.ToString());
436 wWWForm.AddField("idLang", idLang);
437 wWWForm.AddField("msg2", msg2);
438 wWWForm.AddField("msg3", msg3);
439 wWWForm.AddField("msg4", msg4);
440 try
441 {
442 using UnityWebRequest www = UnityWebRequest.Post(urlBook + "book.php", wWWForm);
443 await www.SendWebRequest();
444 if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError)
445 {
446 if (ShowNetError)
447 {
448 EClass.ui.Say(www.error);
449 }
450 return false;
451 }
452 Debug.Log(www.downloadHandler.text);
453 return true;
454 }
455 catch
456 {
457 }
458 }
459 catch
460 {
461 }
462 return false;
463 }
Version version
Definition: BaseCore.cs:17
static Core core
Definition: EClass.cs:7
bool demo
Definition: Version.cs:14

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

◆ SendChat()

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

Definition at line 335 of file Net.cs.

336 {
338 {
339 return false;
340 }
342 {
343 return false;
344 }
345 try
346 {
347 if (EClass.debug.enable)
348 {
349 idLang = "DEBUG";
350 }
351 Debug.Log("Start Sending Text:");
352 WWWForm wWWForm = new WWWForm();
353 wWWForm.AddField("submit", "Send");
354 wWWForm.AddField("name", name);
355 wWWForm.AddField("msg", msg);
356 wWWForm.AddField("cat", cat.ToString());
357 wWWForm.AddField("idLang", idLang);
358 try
359 {
360 using UnityWebRequest www = UnityWebRequest.Post(urlChat + "chat.php", wWWForm);
361 await www.SendWebRequest();
362 if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError)
363 {
364 if (ShowNetError)
365 {
366 EClass.ui.Say(www.error);
367 }
368 return false;
369 }
370 Debug.Log(www.downloadHandler.text);
371 return true;
372 }
373 catch
374 {
375 }
376 }
377 catch
378 {
379 }
380 return false;
381 }
NetSetting net
Definition: CoreConfig.cs:619
CoreConfig config
Definition: Core.cs:70

References Core.config, EClass.core, EClass.debug, Debug, Version.demo, CoreConfig.NetSetting.enable, CoreDebug.enable, CoreConfig.net, CoreConfig.NetSetting.sendEvent, ShowNetError, EClass.ui, and BaseCore.version.

◆ SendVote()

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

Definition at line 256 of file Net.cs.

257 {
258 try
259 {
260 Debug.Log("Start Sending Vote:");
261 WWWForm wWWForm = new WWWForm();
262 wWWForm.AddField("vote", id.ToString() ?? "");
263 wWWForm.AddField("idLang", idLang);
264 wWWForm.AddField("submit", "Send");
265 using UnityWebRequest www = UnityWebRequest.Post(urlVote + "vote.php", wWWForm);
266 await www.SendWebRequest();
267 if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError)
268 {
269 if (ShowNetError)
270 {
271 EClass.ui.Say(www.error);
272 }
273 return false;
274 }
275 Debug.Log(www.downloadHandler.text);
276 return true;
277 }
278 catch
279 {
280 return true;
281 }
282 }

References Debug, ShowNetError, and EClass.ui.

◆ ShowChat()

void Net.ShowChat ( string  logs)
inline

Definition at line 112 of file Net.cs.

113 {
114 foreach (JToken item in (JArray)JsonConvert.DeserializeObject(logs))
115 {
116 ChatLog chatLog = item.ToObject<ChatLog>();
117 Debug.Log(chatLog.name + "/" + chatLog.msg);
118 }
119 }

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

◆ ShowVote()

void Net.ShowVote ( string  logs)
inline

Definition at line 103 of file Net.cs.

104 {
105 StringReader stringReader = new StringReader(logs);
106 for (string text = stringReader.ReadLine(); text != null; text = stringReader.ReadLine())
107 {
108 Debug.Log(text);
109 }
110 }

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 121 of file Net.cs.

122 {
123 if (isUploading)
124 {
125 EClass.ui.Say("sys_uploadUploading");
126 return false;
127 }
128 EClass.ui.Say("sys_uploadStart");
129 byte[] array;
130 using (FileStream fileStream = File.OpenRead(path))
131 {
132 array = new byte[fileStream.Length];
133 fileStream.Read(array, 0, (int)fileStream.Length);
134 }
135 WWWForm wWWForm = new WWWForm();
136 wWWForm.AddField("mode", 1);
137 wWWForm.AddField("id", id.RemoveNewline());
138 wWWForm.AddField("name", name.RemoveNewline());
139 wWWForm.AddField("title", title.RemoveNewline());
140 wWWForm.AddField("cat", cat);
141 wWWForm.AddField("tag", tag);
142 wWWForm.AddField("idLang", idLang);
143 wWWForm.AddField("password", password);
144 wWWForm.AddField("submit", "Send");
145 wWWForm.AddField("version", EClass.core.version.GetInt().ToString() ?? "");
146 wWWForm.AddBinaryData("file", array, "file.z");
147 isUploading = true;
148 Debug.Log(id);
149 Debug.Log(name);
150 Debug.Log(title);
151 Debug.Log(idLang);
152 Debug.Log(password);
153 Debug.Log(tag);
154 Debug.Log(array.Length);
155 using (UnityWebRequest www = UnityWebRequest.Post(urlUpload + "uploader.php", wWWForm))
156 {
157 try
158 {
159 await www.SendWebRequest();
160 Debug.Log(www.result.ToString());
161 Debug.Log(www.downloadHandler.ToString());
162 Debug.Log(www.downloadHandler.text);
163 Debug.Log(www.downloadHandler.text.ToString());
164 }
165 catch (Exception ex)
166 {
167 EClass.ui.Say(ex.Message);
168 }
169 isUploading = false;
170 if (www.result != UnityWebRequest.Result.Success)
171 {
172 EClass.ui.Say((www.responseCode == 401) ? "sys_uploadConflict" : "sys_uploadFail");
173 return false;
174 }
175 }
176 EClass.ui.Say("sys_uploadSuccess");
177 return true;
178 }
static bool isUploading
Definition: Net.cs:89
int GetInt()
Definition: Version.cs:21

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

Member Data Documentation

◆ chatList

List<ChatLog> Net.chatList

Definition at line 77 of file Net.cs.

◆ isUploading

bool Net.isUploading
static

Definition at line 89 of file Net.cs.

◆ urlBook

string Net.urlBook = urlScript + "book/"
static

Definition at line 81 of file Net.cs.

◆ urlChat

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

Definition at line 83 of file Net.cs.

◆ urlScript

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

Definition at line 79 of file Net.cs.

◆ urlUpload

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

Definition at line 87 of file Net.cs.

◆ urlVote

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

Definition at line 85 of file Net.cs.

Property Documentation

◆ ShowNetError

bool Net.ShowNetError
staticget

Definition at line 91 of file Net.cs.

92 {
93 get
94 {
96 {
97 return EClass.debug.enable;
98 }
99 return true;
100 }
101 }

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


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