Fixed bug which caused the UDP and TCP Listeners to shut down on improperly formatted JSON

This commit is contained in:
Eric Fontana
2014-12-12 09:10:49 -05:00
parent 89684844dd
commit 20c16a1ec3
3 changed files with 28 additions and 13 deletions

View File

@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.15.0")]
[assembly: AssemblyFileVersion("1.3.15.0")]
[assembly: AssemblyVersion("1.3.16.0")]
[assembly: AssemblyFileVersion("1.3.16.0")]

View File

@@ -105,10 +105,18 @@ namespace TimberWinR.Inputs
while (reader.Read())
{
if (CancelToken.IsCancellationRequested) break;
try
{
JObject json = JObject.Load(reader);
ProcessJson(json);
_receivedMessages++;
}
catch (Exception ex)
{
LogManager.GetCurrentClassLogger().Warn(ex);
}
}
}
}
}

View File

@@ -77,11 +77,18 @@ namespace TimberWinR.Inputs
while (!CancelToken.IsCancellationRequested)
{
byte[] bytes = profile.client.Receive(ref profile.endPoint);
try
{
var data = Encoding.ASCII.GetString(bytes, 0, bytes.Length);
JObject json = JObject.Parse(data);
ProcessJson(json);
_receivedMessages++;
}
catch (Exception ex1)
{
LogManager.GetCurrentClassLogger().Warn(ex1);
}
}
_udpListener.Close();
}
catch (Exception ex)