Add try-catch to preven the game from crashing
This commit is contained in:
parent
8d9e568cac
commit
691accdeea
1 changed files with 12 additions and 5 deletions
|
@ -30,11 +30,18 @@ namespace TBConsole
|
||||||
_listener.Start();
|
_listener.Start();
|
||||||
while (_running)
|
while (_running)
|
||||||
{
|
{
|
||||||
var context = await _listener.GetContextAsync();
|
try
|
||||||
string resp = await _receiver(await new StreamReader(context.Request.InputStream).ReadToEndAsync());
|
{
|
||||||
var sw = new StreamWriter(context.Response.OutputStream);
|
var context = await _listener.GetContextAsync();
|
||||||
await sw.WriteLineAsync(resp);
|
string resp = await _receiver(await new StreamReader(context.Request.InputStream).ReadToEndAsync());
|
||||||
sw.Close();
|
var sw = new StreamWriter(context.Response.OutputStream);
|
||||||
|
await sw.WriteLineAsync(resp);
|
||||||
|
sw.Close();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue