onSend method
Called for each message before it is queued.
Return the same message to keep it, a modified message to transform it,
or null to drop it.
Implementation
@override
Msg? onSend(Msg msg) {
_queuedMessageCount++;
// Let inner interceptor transform/drop the message first.
final innerResult = inner?.onSend(msg);
// If the inner interceptor exists and dropped the message, propagate.
if (inner != null && innerResult == null) return null;
final transformed = innerResult ?? msg;
// Begin Timeline span for message processing.
if (enableTimeline) {
_currentMsg = transformed;
_messageSw
..reset()
..start();
dev.Timeline.startSync(
'artisanal.message',
arguments: <String, String>{
'type': transformed.runtimeType.toString(),
'summary': _summarizeMsg(transformed),
},
);
}
return transformed;
}