public async Task <string[]> DirAllAsync(string path) { if (string.IsNullOrEmpty(path)) { throw new ArgumentException("invalid path", nameof(path)); } var payload = path.ToNullTerminatedBytes(); var messageheader = new ClientMessageHeader(MessageTypes.DirAll, ControlFlags.Default | ControlFlags.BusRet, payload); var buffer = messageheader.ToByteArray(); return(await InternalDirAsync(payload, messageheader)); }
public async Task SendAsync(ClientMessageHeader header, byte[] payload, CancellationToken token = default) { if (!Connected) { throw new InvalidOperationException("Cannot send. No open connection!"); } var buffer = header.ToByteArray(); await _stream.WriteAsync(buffer, 0, buffer.Length, token); if (payload != null && payload.Length > 0) { await _stream.WriteAsync(payload, 0, payload.Length, token); } await _stream.FlushAsync(token); }