TransportLayerInsecurity.Server.OnAsynchronousRead C# (CSharp) Method

OnAsynchronousRead() private method

private OnAsynchronousRead ( IAsyncResult result ) : void
result IAsyncResult
return void
        void OnAsynchronousRead(IAsyncResult result)
        {
            try
            {
                StreamContext remoteContext = (StreamContext)result.AsyncState;
                int bytesRead = remoteContext.Stream.EndRead(result);
                if (bytesRead == 0)
                {
                    CloseStreams();
                    ServerEventHandler.OnRemoteDisconnect();
                    return;
                }
                byte[] data = remoteContext.Buffer.Take(bytesRead).ToArray();
                LocalStream.Write(data);
                ServerEventHandler.OnServerToClientData(data);
                ReadAsynchronously(remoteContext);
            }
            catch (ObjectDisposedException)
            {
                //This occurs after a disconnect
            }
        }