cache
This commit is contained in:
parent
b2fdb364bf
commit
6f4515cfe3
13
.idea/.idea.Zerolauncher/.idea/.gitignore
vendored
Normal file
13
.idea/.idea.Zerolauncher/.idea/.gitignore
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider 忽略的文件
|
||||
/modules.xml
|
||||
/contentModel.xml
|
||||
/projectSettingsUpdater.xml
|
||||
/.idea.Zerolauncher.iml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
4
.idea/.idea.Zerolauncher/.idea/encodings.xml
Normal file
4
.idea/.idea.Zerolauncher/.idea/encodings.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||
</project>
|
||||
8
.idea/.idea.Zerolauncher/.idea/indexLayout.xml
Normal file
8
.idea/.idea.Zerolauncher/.idea/indexLayout.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/.idea.Zerolauncher/.idea/vcs.xml
Normal file
6
.idea/.idea.Zerolauncher/.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
200
clean_up_code.patch
Normal file
200
clean_up_code.patch
Normal file
@ -0,0 +1,200 @@
|
||||
Subject: [PATCH] clean up code
|
||||
---
|
||||
Index: Manager/WebApiManager.cs
|
||||
IDEA additional info:
|
||||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||||
<+>UTF-8
|
||||
===================================================================
|
||||
diff --git a/Manager/WebApiManager.cs b/Manager/WebApiManager.cs
|
||||
--- a/Manager/WebApiManager.cs (revision 5129f68dadfebc3477fa29452cc914fcbcbb0106)
|
||||
+++ b/Manager/WebApiManager.cs (revision cc94e7fcc8edfcb500c176ec8e111d0f8ca98866)
|
||||
@@ -4,23 +4,23 @@
|
||||
using System.Text;
|
||||
namespace Zerolauncher.Manager
|
||||
{
|
||||
- internal class WebApiManager
|
||||
+ internal static class WebApiManager
|
||||
{
|
||||
- static HttpListener listener = new HttpListener();
|
||||
- static CancellationTokenSource cts = new CancellationTokenSource();
|
||||
+ static readonly HttpListener Listener = new HttpListener();
|
||||
+ static readonly CancellationTokenSource Cts = new CancellationTokenSource();
|
||||
public static async Task StartListener()
|
||||
{
|
||||
- listener.Prefixes.Add("http://127.0.0.1:7233/");
|
||||
- listener.Start();
|
||||
+ Listener.Prefixes.Add("http://127.0.0.1:7233/");
|
||||
+ Listener.Start();
|
||||
Trace.WriteLine("Listening...");
|
||||
|
||||
- while (!cts.Token.IsCancellationRequested)
|
||||
+ while (!Cts.Token.IsCancellationRequested)
|
||||
{
|
||||
- HttpListenerContext context = await listener.GetContextAsync();
|
||||
- HttpListenerRequest request = context.Request;
|
||||
- HttpListenerResponse response = context.Response;
|
||||
+ var context = await Listener.GetContextAsync();
|
||||
+ var request = context.Request;
|
||||
+ var response = context.Response;
|
||||
var raw = request.RawUrl;
|
||||
- ResponesBody? rb = null;
|
||||
+ ResponseBody? rb = null;
|
||||
if (raw != null && raw.Contains("?"))
|
||||
{
|
||||
var lines = raw.Split("?");
|
||||
@@ -34,121 +34,79 @@
|
||||
switch (lines[0])
|
||||
{
|
||||
case "/CloseGame":
|
||||
- {
|
||||
- if (EngineManager.ExitGame(acc))
|
||||
- {
|
||||
- rb = new ResponesBody(1, 0, $"Account [{nick}] successful to close.");
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- rb = new ResponesBody($"Account [{nick}] is unluacher.");
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
+ {
|
||||
+ rb = EngineManager.ExitGame(acc) ? new ResponseBody(1, 0, $"Account [{nick}] successful to close.") : new ResponseBody($"Account [{nick}] is unluacher.");
|
||||
+ }
|
||||
break;
|
||||
case "/ToNormalSize":
|
||||
- {
|
||||
- switch (EngineManager.TurnGameSizeNormal(acc))
|
||||
- {
|
||||
- case 2:
|
||||
- rb = new ResponesBody(1, 0, $"Account [{nick}] now is normal size.");
|
||||
- break;
|
||||
- case 1:
|
||||
- rb = new ResponesBody(0, 0, $"Account [{nick}] is loading, please wait.");
|
||||
- break;
|
||||
- case 0:
|
||||
- rb = new ResponesBody($"Account [{nick}] is unluacher.");
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
+ {
|
||||
+ rb = EngineManager.TurnGameSizeNormal(acc) switch
|
||||
+ {
|
||||
+ 2 => new ResponseBody(1, 0, $"Account [{nick}] now is normal size."),
|
||||
+ 1 => new ResponseBody(0, 0, $"Account [{nick}] is loading, please wait."),
|
||||
+ 0 => new ResponseBody($"Account [{nick}] is unluacher."),
|
||||
+ _ => rb
|
||||
+ };
|
||||
+ }
|
||||
break;
|
||||
case "/ToMiniSize":
|
||||
- {
|
||||
- switch (EngineManager.TurnGameSizeMini(acc))
|
||||
- {
|
||||
- case 2:
|
||||
- rb = new ResponesBody(1, 0, $"Account [{nick}] now is mini size.");
|
||||
- break;
|
||||
- case 1:
|
||||
- rb = new ResponesBody(0, 0, $"Account [{nick}] is loading, please wait.");
|
||||
- break;
|
||||
- case 0:
|
||||
- rb = new ResponesBody($"Account [{nick}] is unluacher.");
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
+ {
|
||||
+ rb = EngineManager.TurnGameSizeMini(acc) switch
|
||||
+ {
|
||||
+ 2 => new ResponseBody(1, 0, $"Account [{nick}] now is mini size."),
|
||||
+ 1 => new ResponseBody(0, 0, $"Account [{nick}] is loading, please wait."),
|
||||
+ 0 => new ResponseBody($"Account [{nick}] is unluacher."),
|
||||
+ _ => rb
|
||||
+ };
|
||||
+ }
|
||||
break;
|
||||
case "/LoginGame":
|
||||
{
|
||||
if (EngineManager.CreateGame(acc))
|
||||
{
|
||||
- rb = new ResponesBody(0, 0, $"Account [{nick}] successful to start.");
|
||||
+ rb = new ResponseBody(0, 0, $"Account [{nick}] successful to start.");
|
||||
}
|
||||
else
|
||||
{
|
||||
- int hwnd = EngineManager.CheckGameState(acc);
|
||||
- if (hwnd <= 0)
|
||||
- {
|
||||
- rb = new ResponesBody(0, 0, $"Account [{nick}] is loading, please wait.");
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- rb = new ResponesBody(1, hwnd, $"Account [{nick}] now is running.");
|
||||
- }
|
||||
+ var hwnd = EngineManager.CheckGameState(acc);
|
||||
+ rb = hwnd <= 0 ? new ResponseBody(0, 0, $"Account [{nick}] is loading, please wait.") : new ResponseBody(1, hwnd, $"Account [{nick}] now is running.");
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
- rb = new ResponesBody($"commad [{lines[0]}] undefind.");
|
||||
+ rb = new ResponseBody($"commad [{lines[0]}] undefind.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
- rb = new ResponesBody($"Account [{nick}] undefind.");
|
||||
+ rb = new ResponseBody($"Account [{nick}] undefind.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
- rb = new ResponesBody("args is missing.");
|
||||
+ rb = new ResponseBody("args is missing.");
|
||||
}
|
||||
|
||||
}
|
||||
- if (rb == null)
|
||||
- {
|
||||
- rb = new ResponesBody();
|
||||
- }
|
||||
- byte[] buffer = Encoding.UTF8.GetBytes(rb.Encode());
|
||||
+ rb ??= new ResponseBody();
|
||||
+ var buffer = Encoding.UTF8.GetBytes(rb.Encode());
|
||||
|
||||
response.ContentLength64 = buffer.Length;
|
||||
- Stream output = response.OutputStream;
|
||||
+ var output = response.OutputStream;
|
||||
await output.WriteAsync(buffer, 0, buffer.Length);
|
||||
output.Close();
|
||||
}
|
||||
- listener.Stop();
|
||||
+ Listener.Stop();
|
||||
}
|
||||
|
||||
- public static void StopListener() { cts.Cancel(); }
|
||||
+ public static void StopListener() { Cts.Cancel(); }
|
||||
}
|
||||
|
||||
- class ResponesBody
|
||||
+ class ResponseBody(int status = -1, int hwnd = 0, string message = "Hello, World!")
|
||||
{
|
||||
- public int status;
|
||||
- public int hwnd;
|
||||
- public string message;
|
||||
-
|
||||
- public ResponesBody(string message)
|
||||
+ public ResponseBody(string message) : this(-1, 0, message)
|
||||
{
|
||||
- this.status = -1;
|
||||
- this.hwnd = 0;
|
||||
- this.message = message;
|
||||
- }
|
||||
-
|
||||
- public ResponesBody(int status=-1, int hwnd=0, string message= "Hello, World!")
|
||||
- {
|
||||
- this.status = status;
|
||||
- this.hwnd = hwnd;
|
||||
- this.message = message;
|
||||
}
|
||||
|
||||
public string Encode()
|
||||
Loading…
Reference in New Issue
Block a user