diff --git a/samples/SocketsSample/EndPoints/RpcEndpoint.cs b/samples/SocketsSample/EndPoints/RpcEndpoint.cs index 29f64884b9..216b310ed3 100644 --- a/samples/SocketsSample/EndPoints/RpcEndpoint.cs +++ b/samples/SocketsSample/EndPoints/RpcEndpoint.cs @@ -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> _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)) { diff --git a/samples/SocketsSample/LineInvocationAdapter.cs b/samples/SocketsSample/LineInvocationAdapter.cs index af1dce60b6..8bed0c94c3 100644 --- a/samples/SocketsSample/LineInvocationAdapter.cs +++ b/samples/SocketsSample/LineInvocationAdapter.cs @@ -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);