Skip to content

Commit

Permalink
fix DefaultGUI conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
KedamaOvO committed Feb 26, 2018
1 parent f0af382 commit 166f069
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 65 deletions.
30 changes: 16 additions & 14 deletions OsuDataDistributeRestfulPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class OsuDataDistributeRestfulPlugin : Plugin
{
public const string PLUGIN_NAME = "OsuDataDistributeRestful";
public const string PLUGIN_AUTHOR = "KedamavOvO";
public const string VERSION = "0.0.5";
public const string VERSION = "0.0.6";

private bool m_http_quit = false;
private HttpListener m_httpd=new HttpListener() { IgnoreWriteExceptions=true};
Expand Down Expand Up @@ -92,7 +92,7 @@ private void Initialize()
if (Setting.EnableFileHttpServer)
{
songsHttpServer = new FileHttpServer();
songsHttpServer.Start();
Task.Run(()=>songsHttpServer.Start());
}
}

Expand All @@ -106,17 +106,8 @@ public void RemappingResource(string uri,string target_uri)
m_url_dict[target_uri] = m_url_dict[uri];
}

public override async void OnEnable()
private async void StartApiHttpServer()
{
Sync.Tools.IO.CurrentIO.WriteColor(PLUGIN_NAME + " By " + PLUGIN_AUTHOR, ConsoleColor.DarkCyan);

Initialize();

if (Setting.AllowLAN)
m_httpd.Prefixes.Add(@"http://+:10800/");
else
m_httpd.Prefixes.Add(@"http://localhost:10800/");

m_httpd.Start();
while (!m_http_quit)
{
Expand All @@ -130,14 +121,14 @@ public override async void OnEnable()
response.ContentEncoding = Encoding.UTF8;
response.ContentType = "text/json; charset=UTF-8";

if(request.HttpMethod=="GET")
if (request.HttpMethod == "GET")
{
if (m_url_dict.TryGetValue(request.Url.AbsolutePath, out var func))
{
var @params = ParseUriParams(request.Url);

var result = func(@params);
if(result is StreamResult sr)
if (result is StreamResult sr)
{
if (sr.Data != null)
{
Expand Down Expand Up @@ -174,6 +165,17 @@ public override async void OnEnable()
}
}

public override void OnEnable()
{
Sync.Tools.IO.CurrentIO.WriteColor(PLUGIN_NAME + " By " + PLUGIN_AUTHOR, ConsoleColor.DarkCyan);
Initialize();
if (Setting.AllowLAN)
m_httpd.Prefixes.Add(@"http://+:10800/");
else
m_httpd.Prefixes.Add(@"http://localhost:10800/");
Task.Run(()=>StartApiHttpServer());
}

public void Return404(HttpListenerResponse response)
{
response.StatusCode = 404;
Expand Down
51 changes: 0 additions & 51 deletions html/rtpp_old.html

This file was deleted.

0 comments on commit 166f069

Please sign in to comment.