Merge pull request #2 from efontana/rel1.x

Better error handling
This commit is contained in:
Eric Fontana
2014-08-19 07:01:06 -04:00

View File

@@ -65,9 +65,11 @@ namespace TimberWinR.Inputs
private void HandleNewClient(object client)
{
var tcpClient = (TcpClient)client;
NetworkStream clientStream = tcpClient.GetStream();
NetworkStream clientStream = null;
do
{
clientStream = tcpClient.GetStream();
var stream = new StreamReader(clientStream);
string line;
while ((line = stream.ReadLine()) != null)
{
@@ -76,12 +78,15 @@ namespace TimberWinR.Inputs
JObject json = JObject.Parse(line);
ProcessJson(json);
}
catch (Exception)
catch (Exception ex)
{
LogManager.GetCurrentClassLogger().Error(ex);
}
if (CancelToken.IsCancellationRequested)
break;
}
} while (!CancelToken.IsCancellationRequested);
clientStream.Close();
tcpClient.Close();
Finished();