-
Notifications
You must be signed in to change notification settings - Fork 0
/
SmokeTest.cs
33 lines (30 loc) · 847 Bytes
/
SmokeTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using protohackers.Transport;
namespace protohackers;
public class SmokeTest : TcpServerBase
{
protected override async Task ProcessConnection(Connection connection)
{
while (true)
{
var result = await connection.Input.ReadAsync();
var buff = result.Buffer;
if (buff.IsSingleSegment)
{
await connection.Output.WriteAsync(buff.First);
}
else
{
foreach (var mem in buff)
{
await connection.Output.WriteAsync(mem);
}
}
connection.Input.AdvanceTo(buff.End);
if (result.IsCompleted || result.IsCanceled)
{
break;
}
}
await connection.Output.CompleteAsync();
}
}