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

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

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

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

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

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

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

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

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

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

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

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: