feat: enforce mqtt auth tls and keepalive semantics
This commit is contained in:
@@ -68,4 +68,22 @@ internal static class MqttRuntimeWire
|
||||
|
||||
return Encoding.UTF8.GetString([.. bytes]);
|
||||
}
|
||||
|
||||
public static async Task<string?> ReadRawAsync(NetworkStream stream, int timeoutMs)
|
||||
{
|
||||
using var timeout = new CancellationTokenSource(timeoutMs);
|
||||
var one = new byte[1];
|
||||
try
|
||||
{
|
||||
var read = await stream.ReadAsync(one.AsMemory(0, 1), timeout.Token);
|
||||
if (read == 0)
|
||||
return null;
|
||||
|
||||
return Encoding.UTF8.GetString(one, 0, read);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
return "__timeout__";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user