Fixing NRE when a client closes connection

This commit is contained in:
moozzyk 2016-10-25 17:38:11 -07:00
parent fd10deba6c
commit ca2a471691
2 changed files with 10 additions and 6 deletions

View File

@ -14,7 +14,6 @@ using SocketsSample.Protobuf;
namespace SocketsSample
{
// This end point implementation is used for framing JSON objects from the stream
public class RpcEndpoint : EndPoint
{
private readonly Dictionary<string, Func<InvocationDescriptor, InvocationResultDescriptor>> _callbacks
@ -58,11 +57,11 @@ namespace SocketsSample
return _paramTypes.TryGetValue(methodName, out types) ? types : null;
});
/* TODO: ?? */
//if (((Channel)connection.Channel).Reading.IsCompleted)
//{
// break;
//}
// Is there a better way of detecting that a connection was closed?
if (invocationDescriptor == null)
{
break;
}
if (_logger.IsEnabled(LogLevel.Debug))
{

View File

@ -12,6 +12,11 @@ namespace SocketsSample
{
var streamReader = new StreamReader(stream);
var line = await streamReader.ReadLineAsync();
if (line == null)
{
return null;
}
var values = line.Split(',');
var method = values[1].Substring(1);