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

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

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

413 {
415 {
416 return false;
417 }
418 try
419 {
420 if (EClass.debug.enable)
421 {
422 idLang = "DEBUG";
423 }
424 Debug.Log("Start Sending Book:");
425 WWWForm wWWForm = new WWWForm();
426 wWWForm.AddField("submit", "Send");
427 wWWForm.AddField("name", name);
428 wWWForm.AddField("msg", msg);
429 wWWForm.AddField("cat", cat.ToString());
430 wWWForm.AddField("idLang", idLang);
431 wWWForm.AddField("msg2", msg2);
432 wWWForm.AddField("msg3", msg3);
433 wWWForm.AddField("msg4", msg4);
434 try
435 {
436 using UnityWebRequest www = UnityWebRequest.Post(urlBook + "book.php", wWWForm);
437 await www.SendWebRequest();
438 if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError)
439 {
440 if (ShowNetError)
441 {
442 EClass.ui.Say(www.error);
443 }
444 return false;
445 }
446 Debug.Log(www.downloadHandler.text);
447 return true;
448 }
449 catch
450 {
451 }
452 }
453 catch
454 {
455 }
456 return false;
457 }
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 }
339 try
340 {
341 if (EClass.debug.enable)
342 {
343 idLang = "DEBUG";
344 }
345 Debug.Log("Start Sending Text:");
346 WWWForm wWWForm = new WWWForm();
347 wWWForm.AddField("submit", "Send");
348 wWWForm.AddField("name", name);
349 wWWForm.AddField("msg", msg);
350 wWWForm.AddField("cat", cat.ToString());
351 wWWForm.AddField("idLang", idLang);
352 try
353 {
354 using UnityWebRequest www = UnityWebRequest.Post(urlChat + "chat.php", wWWForm);
355 await www.SendWebRequest();
356 if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError)
357 {
358 if (ShowNetError)
359 {
360 EClass.ui.Say(www.error);
361 }
362 return false;
363 }
364 Debug.Log(www.downloadHandler.text);
365 return true;
366 }
367 catch
368 {
369 }
370 }
371 catch
372 {
373 }
374 return false;
375 }

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 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 }
CoreConfig config
Definition: Core.cs:70

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


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