FubarDev.FtpServer.FtpConnection.WriteAsync C# (CSharp) Method

WriteAsync() public method

Writes a FTP response to a client
public WriteAsync ( [ response, CancellationToken cancellationToken ) : Task
response [ The response to write to the client
cancellationToken System.Threading.CancellationToken The cancellation token
return Task
        public async Task WriteAsync([NotNull] FtpResponse response, CancellationToken cancellationToken)
        {
            if (!_closed)
            {
                Log?.Log(response);
                var data = Encoding.GetBytes($"{response}\r\n");
                await SocketStream.WriteAsync(data, 0, data.Length, cancellationToken);
                response.AfterWriteAction?.Invoke();
            }
        }