public bool SendCommand(CommandRequest command) { bool result = false; if (disposedValue) { return(result); } byte[] buffer = command.SerializeCommand(); lock (clientLocker) { try { if (!Client.Connected) { Reconnect(); } byte[] metaData = BitConverter.GetBytes(buffer.Length); byte[] resultBuffer = new byte[metaData.Length + buffer.Length]; Array.Copy(metaData, 0, resultBuffer, 0, metaData.Length); Array.Copy(buffer, 0, resultBuffer, metaData.Length, buffer.Length); Stream.Write(resultBuffer, 0, resultBuffer.Length); result = true; } catch (Exception ex) { //ConsoleOutput.WriteLineError($"Ошибка при отправки сообщения '{ex}'"); } } return(result); }