Elin Decompiled Documentation EA 23.290 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 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 179 of file Net.cs.

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

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

Referenced by TraitMoongate.UseMoongate().

◆ GetBook()

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

Definition at line 463 of file Net.cs.

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

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

◆ GetChat()

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

Definition at line 381 of file Net.cs.

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

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

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

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

References ShowNetError, EClass.ui, and urlVote.

Referenced by LayerNewspaper.RefreshVote().

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

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

◆ SendChat()

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

Definition at line 333 of file Net.cs.

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

Referenced by Scene.OnUpdate(), and ActEffect.Wish().

◆ SendVote()

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

Definition at line 254 of file Net.cs.

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

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

Referenced by LayerNewspaper.RefreshVote().

◆ ShowChat()

void Net.ShowChat ( string  logs)
inline

Definition at line 111 of file Net.cs.

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

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

◆ ShowVote()

void Net.ShowVote ( string  logs)
inline

Definition at line 102 of file Net.cs.

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

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

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

◆ isUploading

bool Net.isUploading
static

Definition at line 88 of file Net.cs.

Referenced by UploadFile().

◆ urlBook

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

Definition at line 80 of file Net.cs.

Referenced by GetBook(), and SendBook().

◆ urlChat

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

Definition at line 82 of file Net.cs.

Referenced by GetChat(), and SendChat().

◆ urlScript

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

Definition at line 78 of file Net.cs.

◆ urlUpload

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

Definition at line 86 of file Net.cs.

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

◆ urlVote

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

Definition at line 84 of file Net.cs.

Referenced by GetVote(), and SendVote().

Property Documentation

◆ ShowNetError

bool Net.ShowNetError
staticget

Definition at line 90 of file Net.cs.

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

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


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