Elin Decompiled Documentation EA 23.130 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, string cat="Home")
 
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 160 of file Net.cs.

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

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

358 {
359 List<ChatLog> list = new List<ChatLog>();
360 try
361 {
362 if (EClass.debug.enable)
363 {
364 idLang = "DEBUG";
365 }
366 string uri = $"http://ylva.php.xdomain.jp/script/chat/logs/all_{idLang}.json";
367 using UnityWebRequest www = UnityWebRequest.Get(uri);
368 await www.SendWebRequest();
369 if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError)
370 {
371 return null;
372 }
373 Debug.Log("Download Chat Logs: Success");
374 foreach (JToken item in (JArray)JsonConvert.DeserializeObject(www.downloadHandler.text))
375 {
376 list.Add(item.ToObject<ChatLog>());
377 }
378 foreach (ChatLog item2 in list)
379 {
380 item2.msg = item2.msg.Replace("\n", "").Replace("\r", "").Replace("&quot;", "\"")
381 .ToTitleCase();
382 }
383 list.Reverse();
384 return list;
385 }
386 catch
387 {
388 return list;
389 }
390 }
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 193 of file Net.cs.

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

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

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

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

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

References Debug, ShowNetError, and EClass.ui.

Referenced by LayerNewspaper.RefreshVote().

◆ ShowChat()

void Net.ShowChat ( string  logs)
inline

Definition at line 94 of file Net.cs.

95 {
96 foreach (JToken item in (JArray)JsonConvert.DeserializeObject(logs))
97 {
98 ChatLog chatLog = item.ToObject<ChatLog>();
99 Debug.Log(chatLog.name + "/" + chatLog.msg);
100 }
101 }

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

◆ ShowVote()

void Net.ShowVote ( string  logs)
inline

Definition at line 85 of file Net.cs.

86 {
87 StringReader stringReader = new StringReader(logs);
88 for (string text = stringReader.ReadLine(); text != null; text = stringReader.ReadLine())
89 {
90 Debug.Log(text);
91 }
92 }

References Debug.

◆ UploadFile()

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

Definition at line 103 of file Net.cs.

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

◆ isUploading

bool Net.isUploading
static

Definition at line 71 of file Net.cs.

Referenced by UploadFile().

◆ urlChat

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

Definition at line 65 of file Net.cs.

◆ urlScript

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

Definition at line 63 of file Net.cs.

◆ urlUpload

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

Definition at line 69 of file Net.cs.

◆ urlVote

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

Definition at line 67 of file Net.cs.

Property Documentation

◆ ShowNetError

bool Net.ShowNetError
staticget

Definition at line 73 of file Net.cs.

74 {
75 get
76 {
78 {
79 return EClass.debug.enable;
80 }
81 return true;
82 }
83 }
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: