Skip to content

Conversation

@MinyazevR
Copy link
Owner

No description provided.


private readonly CancellationTokenSource source = new();

public CancellationTokenSource GetSource => source;

Choose a reason for hiding this comment

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

Свойства обычно не именуют с Get

this.address = adress;
}

// Принять сообщение

Choose a reason for hiding this comment

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

Для private-функции XML Documentation тоже вполне можно писать. Обычные комментарии используются для комментирования внутри тел методов в основном.

// Принять сообщение
private async Task GetMessage(NetworkStream stream) {
using var streamReader = new StreamReader(stream);
var data = (await streamReader.ReadLineAsync());

Choose a reason for hiding this comment

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

Suggested change
var data = (await streamReader.ReadLineAsync());
var data = await streamReader.ReadLineAsync();

// Отправить сообщение
private async Task SendMessage(NetworkStream stream)
{
using var streamWriter = new StreamWriter(stream) { AutoFlush = true};

Choose a reason for hiding this comment

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

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

{
break;
}
}

Choose a reason for hiding this comment

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

Тут ни одного блокирующего вызова нет — цикл, производящий миллионы задач просто


private readonly CancellationTokenSource source = new();

public CancellationTokenSource GetSource => source ;

Choose a reason for hiding this comment

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

Suggested change
public CancellationTokenSource GetSource => source ;
public CancellationTokenSource GetSource => source;

// Блокируем поток до установления соединения
var acceptedSocket = await tcpListener.AcceptSocketAsync();
// Поток для записи и чтения в полученный сокет
using var newtworkStream = new NetworkStream(acceptedSocket);

Choose a reason for hiding this comment

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

networkStream

Comment on lines +43 to +44
Task a = Task.Run(() => SendMessage(newtworkStream));
Task b = Task.Run(() => GetMessage(newtworkStream));

Choose a reason for hiding this comment

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

Их бы запоминать и подождать в конце метода


public class Tests2Tests
{
Server? server;

Choose a reason for hiding this comment

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

private

[Test]
public void Test1()
{

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