Elin Decompiled Documentation EA 23.102 Nightly
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)
 
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 bool isUploading
 

Properties

static bool ShowNetError [get]
 

Static Private Attributes

const string urlScript = "http://ylva.php.xdomain.jp/script/"
 
const string urlChat = "http://ylva.php.xdomain.jp/script/chat/"
 
const string urlVote = "http://ylva.php.xdomain.jp/script/vote/"
 
const string urlUpload = "http://ylva.php.xdomain.jp/script/uploader/"
 

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

155 {
156 string fn = item.id + ".z";
157 DownloadCahce caches = IO.LoadFile<DownloadCahce>(CorePath.ZoneSaveUser + "cache.txt") ?? new DownloadCahce();
158 if (caches.items.TryGetValue(item.id) == item.date.Replace("\"", "") && File.Exists(path + fn))
159 {
160 Debug.Log("Returning Cache:" + path + fn);
161 return new FileInfo(path + fn);
162 }
163 using UnityWebRequest www = UnityWebRequest.Get("http://ylva.php.xdomain.jp/script/uploader/files/" + idLang + "/" + fn);
164 www.downloadHandler = new DownloadHandlerFile(path + fn);
165 try
166 {
167 await www.SendWebRequest();
168 }
169 catch (Exception ex)
170 {
171 EClass.ui.Say(ex.Message);
172 }
173 FileInfo fileInfo = new FileInfo(path + fn);
174 if (!fileInfo.Exists || www.result != UnityWebRequest.Result.Success)
175 {
176 if (ShowNetError)
177 {
178 EClass.ui.Say(www.error);
179 }
180 return null;
181 }
182 caches.items[item.id] = item.date;
183 IO.SaveFile(CorePath.ZoneSaveUser + "cache.txt", caches);
184 return fileInfo;
185 }
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:68

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

Referenced by TraitMoongate.UseMoongate().

◆ GetChat()

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

Definition at line 350 of file Net.cs.

351 {
352 List<ChatLog> list = new List<ChatLog>();
353 try
354 {
355 if (EClass.debug.enable)
356 {
357 idLang = "DEBUG";
358 }
359 string uri = $"http://ylva.php.xdomain.jp/script/chat/logs/all_{idLang}.json";
360 using UnityWebRequest www = UnityWebRequest.Get(uri);
361 await www.SendWebRequest();
362 if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError)
363 {
364 return null;
365 }
366 Debug.Log("Download Chat Logs: Success");
367 foreach (JToken item in (JArray)JsonConvert.DeserializeObject(www.downloadHandler.text))
368 {
369 list.Add(item.ToObject<ChatLog>());
370 }
371 foreach (ChatLog item2 in list)
372 {
373 item2.msg = item2.msg.Replace("\n", "").Replace("\r", "").Replace("&quot;", "\"")
374 .ToTitleCase();
375 }
376 list.Reverse();
377 return list;
378 }
379 catch
380 {
381 return list;
382 }
383 }
bool enable
Definition: CoreDebug.cs:285
static CoreDebug debug
Definition: EClass.cs:48

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

Referenced by LayerNewspaper.RefreshChat().

◆ GetFileList()

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

Definition at line 187 of file Net.cs.

188 {
189 List<DownloadMeta> list = new List<DownloadMeta>();
190 using UnityWebRequest www = UnityWebRequest.Get("http://ylva.php.xdomain.jp/script/uploader/files/" + idLang + "/index.txt");
191 try
192 {
193 await www.SendWebRequest();
194 }
195 catch (Exception ex)
196 {
197 EClass.ui.Say(ex.Message);
198 }
199 if (www.result != UnityWebRequest.Result.Success)
200 {
201 if (ShowNetError)
202 {
203 EClass.ui.Say(www.error);
204 }
205 return null;
206 }
207 StringReader stringReader = new StringReader(www.downloadHandler.text);
208 for (string text = stringReader.ReadLine(); text != null; text = stringReader.ReadLine())
209 {
210 if (!string.IsNullOrEmpty(text))
211 {
212 string[] array = text.Split(',');
213 list.Add(new DownloadMeta
214 {
215 path = array[0],
216 id = array[1].Replace("\"", ""),
217 name = array[2],
218 title = array[3],
219 date = array[6].Replace("\"", ""),
220 version = ((array.Length >= 9) ? array[8].ToInt() : 0)
221 });
222 }
223 }
224 return list;
225 }
item3. title
Definition: UIBook.cs:616

References ShowNetError, title, and EClass.ui.

Referenced by TraitMoongate.UseMoongate().

◆ GetVote()

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

Definition at line 255 of file Net.cs.

256 {
257 List<VoteLog> list = new List<VoteLog>();
258 try
259 {
260 string uri = $"http://ylva.php.xdomain.jp/script/vote/logs/data_{idLang}.txt";
261 using UnityWebRequest www = UnityWebRequest.Get(uri);
262 await www.SendWebRequest();
263 if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError)
264 {
265 if (ShowNetError)
266 {
267 EClass.ui.Say(www.error);
268 }
269 }
270 else
271 {
272 StringReader stringReader = new StringReader(www.downloadHandler.text);
273 int num = 0;
274 for (string text = stringReader.ReadLine(); text != null; text = stringReader.ReadLine())
275 {
276 string[] array = text.Split(',');
277 if (num == 0)
278 {
279 list.Add(new VoteLog
280 {
281 name = array[0].Replace("\"", ""),
282 time = array[2].ToInt(),
283 index = num
284 });
285 }
286 else
287 {
288 list.Add(new VoteLog
289 {
290 name = array[0].Replace("\"", ""),
291 count = array[1].ToInt(),
292 index = num
293 });
294 }
295 num++;
296 }
297 }
298 return list;
299 }
300 catch
301 {
302 return list;
303 }
304 }

References $, ShowNetError, and EClass.ui.

Referenced by LayerNewspaper.RefreshVote().

◆ SendChat()

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

Definition at line 306 of file Net.cs.

307 {
309 {
310 return false;
311 }
312 try
313 {
314 if (EClass.debug.enable)
315 {
316 idLang = "DEBUG";
317 }
318 Debug.Log("Start Sending Text:");
319 WWWForm wWWForm = new WWWForm();
320 wWWForm.AddField("submit", "Send");
321 wWWForm.AddField("name", name);
322 wWWForm.AddField("msg", msg);
323 wWWForm.AddField("cat", cat.ToString());
324 wWWForm.AddField("idLang", idLang);
325 try
326 {
327 using UnityWebRequest www = UnityWebRequest.Post("http://ylva.php.xdomain.jp/script/chat/chat.php", wWWForm);
328 await www.SendWebRequest();
329 if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError)
330 {
331 if (ShowNetError)
332 {
333 EClass.ui.Say(www.error);
334 }
335 return false;
336 }
337 Debug.Log(www.downloadHandler.text);
338 return true;
339 }
340 catch
341 {
342 }
343 }
344 catch
345 {
346 }
347 return false;
348 }
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, and BaseCore.version.

Referenced by ActEffect.Wish().

◆ SendVote()

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

Definition at line 227 of file Net.cs.

228 {
229 try
230 {
231 Debug.Log("Start Sending Vote:");
232 WWWForm wWWForm = new WWWForm();
233 wWWForm.AddField("vote", id.ToString() ?? "");
234 wWWForm.AddField("idLang", idLang);
235 wWWForm.AddField("submit", "Send");
236 using UnityWebRequest www = UnityWebRequest.Post("http://ylva.php.xdomain.jp/script/vote/vote.php", wWWForm);
237 await www.SendWebRequest();
238 if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError)
239 {
240 if (ShowNetError)
241 {
242 EClass.ui.Say(www.error);
243 }
244 return false;
245 }
246 Debug.Log(www.downloadHandler.text);
247 return true;
248 }
249 catch
250 {
251 return true;
252 }
253 }

References Debug, ShowNetError, and EClass.ui.

Referenced by LayerNewspaper.RefreshVote().

◆ ShowChat()

void Net.ShowChat ( string  logs)
inline

Definition at line 88 of file Net.cs.

89 {
90 foreach (JToken item in (JArray)JsonConvert.DeserializeObject(logs))
91 {
92 ChatLog chatLog = item.ToObject<ChatLog>();
93 Debug.Log(chatLog.name + "/" + chatLog.msg);
94 }
95 }

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

◆ ShowVote()

void Net.ShowVote ( string  logs)
inline

Definition at line 79 of file Net.cs.

80 {
81 StringReader stringReader = new StringReader(logs);
82 for (string text = stringReader.ReadLine(); text != null; text = stringReader.ReadLine())
83 {
84 Debug.Log(text);
85 }
86 }

References Debug.

◆ UploadFile()

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

Definition at line 97 of file Net.cs.

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

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

Referenced by LayerUploader.Upload().

Member Data Documentation

◆ chatList

List<ChatLog> Net.chatList

Definition at line 55 of file Net.cs.

◆ isUploading

bool Net.isUploading
static

Definition at line 65 of file Net.cs.

Referenced by UploadFile().

◆ urlChat

const string Net.urlChat = "http://ylva.php.xdomain.jp/script/chat/"
staticprivate

Definition at line 59 of file Net.cs.

◆ urlScript

const string Net.urlScript = "http://ylva.php.xdomain.jp/script/"
staticprivate

Definition at line 57 of file Net.cs.

◆ urlUpload

const string Net.urlUpload = "http://ylva.php.xdomain.jp/script/uploader/"
staticprivate

Definition at line 63 of file Net.cs.

◆ urlVote

const string Net.urlVote = "http://ylva.php.xdomain.jp/script/vote/"
staticprivate

Definition at line 61 of file Net.cs.

Property Documentation

◆ ShowNetError

bool Net.ShowNetError
staticget

Definition at line 67 of file Net.cs.

68 {
69 get
70 {
72 {
73 return EClass.debug.enable;
74 }
75 return true;
76 }
77 }
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: