Skip to content

Conversation

@MinyazevR
Copy link
Owner

No description provided.

Comment on lines +33 to +36
var server = new Server.Server(ip!, port);
var cancelTokenSource = new CancellationTokenSource();
var serverTask = Task.Run(() => server.Start(cancelTokenSource), cancelTokenSource.Token);
var client = new Server.Client(ip!, port);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Очень странно запускать сразу и сервер и клиент.Система сама с собой по сети общается?

/// </summary>
/// <param name="stream">stream</param>
/// <param name="path">path to directory</param>
/// <returns></returns>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Пустые тэги не нужны

// Получаем поток для записи и чтения
using var stream = client.GetStream();


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Две пустые строки подряд — тоже :)

using var streamWriter = new StreamWriter(stream) { AutoFlush = true };

// Отправляем сообщение подключенному tcpсерверу.
await streamWriter.WriteLineAsync($"list {pathToDiretory}");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нарушение протокола, list в условии кодируется единицей

i++;
}

return (size, list);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Список сам знает свой размер, так что size несколько избыточен


for (int i = 2; i < args.Length; i++)
{
switch(args[i])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
switch(args[i])
switch (args[i])

{
case "list":
{
var (size, names) = await Task.Run(() => client.List(args[i + 1]));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var (size, names) = await Task.Run(() => client.List(args[i + 1]));
var (size, names) = await client.List(args[i + 1]);

async-методы и так Task всегда возвращают, уже исполняющийся. Оборачивать их с помощью Task.Run нет смысла. Тут и много где ещё.


public class Tests
{
Server? server;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private

}

var server = new Server.Server(ip!, port);
var cancelTokenSource = new CancellationTokenSource();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

По-хорошему, сервер надо остановить в конце и дождаться остановки

Console.WriteLine($"size : {size}");
for (int j = 0; j < bytes.Length; j++)
{
Console.Write(bytes[j]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не, надо бы в файл писать

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants