Conversation
Added tests and comments
Changed tests Added comments
yurii-litvinov
suggested changes
Dec 26, 2022
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); |
There was a problem hiding this comment.
Очень странно запускать сразу и сервер и клиент.Система сама с собой по сети общается?
| /// </summary> | ||
| /// <param name="stream">stream</param> | ||
| /// <param name="path">path to directory</param> | ||
| /// <returns></returns> |
| // Получаем поток для записи и чтения | ||
| using var stream = client.GetStream(); | ||
|
|
||
|
|
There was a problem hiding this comment.
Две пустые строки подряд — тоже :)
| using var streamWriter = new StreamWriter(stream) { AutoFlush = true }; | ||
|
|
||
| // Отправляем сообщение подключенному tcpсерверу. | ||
| await streamWriter.WriteLineAsync($"list {pathToDiretory}"); |
There was a problem hiding this comment.
Нарушение протокола, list в условии кодируется единицей
| i++; | ||
| } | ||
|
|
||
| return (size, list); |
There was a problem hiding this comment.
Список сам знает свой размер, так что size несколько избыточен
|
|
||
| for (int i = 2; i < args.Length; i++) | ||
| { | ||
| switch(args[i]) |
There was a problem hiding this comment.
Suggested change
| switch(args[i]) | |
| switch (args[i]) |
| { | ||
| case "list": | ||
| { | ||
| var (size, names) = await Task.Run(() => client.List(args[i + 1])); |
There was a problem hiding this comment.
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; |
| } | ||
|
|
||
| var server = new Server.Server(ip!, port); | ||
| var cancelTokenSource = new CancellationTokenSource(); |
There was a problem hiding this comment.
По-хорошему, сервер надо остановить в конце и дождаться остановки
| Console.WriteLine($"size : {size}"); | ||
| for (int j = 0; j < bytes.Length; j++) | ||
| { | ||
| Console.Write(bytes[j]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.