Parcel
This extension for Channels implements a set of adapters to encode and decode data using the Parcel protocol.
Getting started
Install the package from NuGet
To enable the decoding and encoding of Parcel packets, use the following to register with the pipelines.
Data Types
The decoder adapter will decode binary packets and forward a Parcel.Message[] array, which you can then use on your own adapters and/or handlers.
Here's an example. Since the base class handles T <--> T[] type mutation, we can choose to handle the data as an array or as a single record. For this example, we'll use a single record.
public class MyMessageHandler : ChannelHandler<Message>
{
public override Task ExecuteAsync( IChannelContext context, Message message, CancellationToken cancellationToken )
{
// ...
}
}
The encoder adapter will encode Parcel.Message objects into binary packets, which will be written to the channel's underlying socket.
Correlation
When using the Parcel protocol, it is common to have request/response flows. The correlation extension provides a way to correlate requests with their responses, allowing you to write code that waits for a specific response after sending a request.
To learn more about correlation, see the correlation documentation.
Note
The older Observable API for Parcel is no longer supported. The new correlation API should be used instead.