onData method
- IsolatePayload data
Handles data coming from the child isolates.
- If a FramePayload comes, sends the frame and details to the Dashboard
- If a DepthFramePayload comes, sends the depth data to autonomy
- If a LogPayload comes, logs the message using logger.
Implementation
void onData(IsolatePayload data) {
switch (data) {
case FramePayload(:final image, :final details):
collection.videoServer.sendMessage(VideoData(frame: image, details: details));
case DepthFramePayload():
collection.videoServer.sendMessage(VideoData(frame: data.frame.depthFrame), destination: autonomySocket);
data.dispose();
case LogPayload(): switch (data.level) {
// Turns out using deprecated members when you *have* to still results in a lint.
// See https://github.com/dart-lang/linter/issues/4852 for why we ignore it.
case LogLevel.all: logger.info(data.message);
// ignore: deprecated_member_use
case LogLevel.verbose: logger.trace(data.message);
case LogLevel.trace: logger.trace(data.message);
case LogLevel.debug: logger.debug(data.message);
case LogLevel.info: logger.info(data.message);
case LogLevel.warning: logger.warning(data.message);
case LogLevel.error: logger.error(data.message);
// ignore: deprecated_member_use
case LogLevel.wtf: logger.info(data.message);
case LogLevel.fatal: logger.critical(data.message);
// ignore: deprecated_member_use
case LogLevel.nothing: logger.info(data.message);
case LogLevel.off: logger.info(data.message);
}
}
}