Message<D, M extends MessageTypeMapping<D> , T extends MessageType<D, M> > constructor
Message<D, M extends MessageTypeMapping<D> , T extends MessageType<D, M> > ({
- String? uId,
- required T messageType,
- required IList<
D> data, - required M mapping,
- DateTime? timestamp,
- MessageTiming? timing,
Creates a new Message with the given parameters.
The messageType parameter specifies the MessageType of the message.
The data parameter must be a list of data with length equal to the
number of channels specified in the messageType.
The uId parameter is optional and will be generated if not provided.
The timestamp parameter is optional and will be set to the current time
if not provided.
The timing parameter is set by transports on the receive path; messages
constructed locally leave it null.
Implementation
Message({
String? uId,
required this.messageType,
required this.data,
required M mapping,
DateTime? timestamp,
this.timing,
}) : _mapping = mapping,
uId = uId ??= generateUid(),
timestamp = timestamp ?? DateTime.now() {
if (data.length != mapping.channels) {
validate();
}
}