more uniform usage of this
This commit is contained in:
parent
81fbc36b77
commit
6ce91bbae7
@ -19,20 +19,20 @@ internal class GSIServer
|
|||||||
{
|
{
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
string prefix = $"http://127.0.0.1:{port}/";
|
string prefix = $"http://127.0.0.1:{port}/";
|
||||||
HttpListener = new HttpListener();
|
this.HttpListener = new HttpListener();
|
||||||
HttpListener.Prefixes.Add(prefix);
|
this.HttpListener.Prefixes.Add(prefix);
|
||||||
HttpListener.Start();
|
this.HttpListener.Start();
|
||||||
this.logger?.Log(LogLevel.Information, $"Listening on {prefix}");
|
this.logger?.Log(LogLevel.Information, $"Listening on {prefix}");
|
||||||
|
|
||||||
Thread connectionListener = new (HandleConnection);
|
Thread connectionListener = new (HandleConnection);
|
||||||
connectionListener.Start();
|
connectionListener.Start();
|
||||||
|
|
||||||
IsRunning = true;
|
this.IsRunning = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void HandleConnection()
|
private async void HandleConnection()
|
||||||
{
|
{
|
||||||
while (_keepRunning)
|
while (this._keepRunning)
|
||||||
{
|
{
|
||||||
HttpListenerContext context = await HttpListener.GetContextAsync();
|
HttpListenerContext context = await HttpListener.GetContextAsync();
|
||||||
HttpListenerRequest request = context.Request;
|
HttpListenerRequest request = context.Request;
|
||||||
@ -47,15 +47,15 @@ internal class GSIServer
|
|||||||
this.logger?.Log(LogLevel.Debug, $"Message Content:\n{content}");
|
this.logger?.Log(LogLevel.Debug, $"Message Content:\n{content}");
|
||||||
OnMessage?.Invoke(content);
|
OnMessage?.Invoke(content);
|
||||||
}
|
}
|
||||||
HttpListener.Close();
|
this.HttpListener.Close();
|
||||||
IsRunning = false;
|
this.IsRunning = false;
|
||||||
this.logger?.Log(LogLevel.Information, "Stopped GSIServer.");
|
this.logger?.Log(LogLevel.Information, "Stopped GSIServer.");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Dispose()
|
internal void Dispose()
|
||||||
{
|
{
|
||||||
this.logger?.Log(LogLevel.Information, "Stopping GSIServer.");
|
this.logger?.Log(LogLevel.Information, "Stopping GSIServer.");
|
||||||
_keepRunning = false;
|
this._keepRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user