PluginAwareMessageCodec.fromPlugins constructor
PluginAwareMessageCodec.fromPlugins({
- required MessageCodec<
Message> defaultCodec, - required List<
SyncPlugin> plugins,
The codec of the protocol plus one per plugin, picked by message type.
A message in the plugin range (from MessageTypeValue.firstPluginValue)
belongs to a plugin; anything below it belongs to the protocol. encode
routes on that, so a plugin's codec is the one that writes its own
messages. decode has bytes rather than a message, so it asks each codec
in turn and takes the first that reads them — a codec answers null for a
frame that is not its own.
Either way null means no codec here handles that message, which is what
a peer running a plugin this build does not have looks like.
Takes the codec of every plugin in plugins.
Implementation
factory PluginAwareMessageCodec.fromPlugins({
required MessageCodec<Message> defaultCodec,
required List<SyncPlugin> plugins,
}) {
return PluginAwareMessageCodec(
defaultCodec: defaultCodec,
pluginCodecs: plugins.map((e) => e.messageCodec).toList(),
);
}