HTTP Streaming Adapter¶
This is a synthetic example for a device with REST commands, a long-lived event stream, and periodic health polling.
Event Flow¶
Command Flow¶
Transport Sketch¶
public partial class Transport
{
private HttpClient? _http;
public HttpClient Http => _http ?? throw new InvalidOperationException();
}
Protocol Sketch¶
public partial class Protocol
{
public Task<XDocument> GetStatus() => Enqueue(async _ =>
{
var xml = await Transport.Http.GetStringAsync("/status");
return XDocument.Parse(xml);
});
}
Notes¶
- serialize protocol access unless the device explicitly supports concurrent requests
- keep parsing, routing, and command logic separate