# MessageGroup

The MessageGroup message type is a versatile container used in DepthAI pipelines to group together a map of arbitrary DepthAI
messages. It serves as the primary output of the
[Sync](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes/sync.md) node, effectively synchronizing various
input streams, and acts as the input to the
[MessageDemux](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes/message_demux.md) node for subsequent
disaggregation and processing.

## Creating MessageGroup

MessageGroup can be created automatically by the Sync node as it aligns and groups messages from different sources based on their
timestamps. Alternatively, it can be manually constructed in a host application or within a
[Script](https://docs.luxonis.com/software-v3/depthai/depthai-components/nodes/script.md) node to create custom groupings of
DepthAI messages.

## Reference

### dai::MessageGroup

Kind: class

MessageGroup message. Carries multiple messages in one.

#### std::map< std::string, std::shared_ptr< ADatatype > > group

Kind: variable

#### ~MessageGroup()

Kind: function

#### std::shared_ptr< ADatatype > operator[](const std::string & name)

Kind: function

Group.

#### std::shared_ptr< T > get(const std::string & name)

Kind: function

#### std::shared_ptr< ADatatype > get(const std::string & name)

Kind: function

#### void add(const std::string & name, const std::shared_ptr< ADatatype > & value)

Kind: function

#### std::map< std::string, std::shared_ptr< ADatatype > >::iterator begin()

Kind: function

#### std::map< std::string, std::shared_ptr< ADatatype > >::iterator end()

Kind: function

#### bool isSynced(int64_t thresholdNs)

Kind: function

True if all messages in the group are in the interval parameters: thresholdNs: Maximal interval between messages

#### int64_t getIntervalNs()

Kind: function

Retrieves interval between the first and the last message in the group.

#### int64_t getNumMessages()

Kind: function

#### std::vector< std::string > getMessageNames()

Kind: function

Gets the names of messages in the group

#### void serialize(std::vector< std::uint8_t > & metadata, DatatypeEnum & datatype)

Kind: function

#### DatatypeEnum getDatatype()

Kind: function

Get the datatype of this specific message.

return: DatatypeEnum

#### DEPTHAI_SERIALIZE(MessageGroup, group, Buffer::ts, Buffer::tsDevice, Buffer::sequenceNum)

Kind: function

### Need assistance?

Head over to [Discussion Forum](https://discuss.luxonis.com/) for technical support or any other questions you might have.
