Browse Source

Add try-catch to preven the game from crashing

tags/v1.0.0
NorbiPeti 3 years ago
parent
commit
691accdeea
Signed by: NorbiPeti <szatmari.norbert.peter@gmail.com> GPG Key ID: DBA4C4549A927E56
1 changed files with 12 additions and 5 deletions
  1. +12
    -5
      TBConsole/WebServer.cs

+ 12
- 5
TBConsole/WebServer.cs View File

@@ -30,11 +30,18 @@ namespace TBConsole
_listener.Start();
while (_running)
{
var context = await _listener.GetContextAsync();
string resp = await _receiver(await new StreamReader(context.Request.InputStream).ReadToEndAsync());
var sw = new StreamWriter(context.Response.OutputStream);
await sw.WriteLineAsync(resp);
sw.Close();
try
{
var context = await _listener.GetContextAsync();
string resp = await _receiver(await new StreamReader(context.Request.InputStream).ReadToEndAsync());
var sw = new StreamWriter(context.Response.OutputStream);
await sw.WriteLineAsync(resp);
sw.Close();
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
}
}

Loading…
Cancel
Save