OpenHiva::Publisher::Publish

Description

Publishes messages.

Prototype

  • Serializing user inputs

    uint32_t OpenHiva::Publisher::Publish(const std::function<bool (uint8_t *, uint32_t)> &serializeFunc, const uint32_t bufferLength)

  • Publishing HivaMessage messages

    uint32_t OpenHiva::Publisher::Publish(const HivaMessage &message)

Parameters

  • Serializing user inputs

    Parameter

    Input/Output

    Description

    serializeFunc

    Input

    Serialization callback function.

    bufferLength

    Input

    Length of the serialized message.

  • Publishing HivaMessage messages

    Parameter

    Input/Output

    Description

    message

    Input

    Message to be published. For details, see OpenHiva::HivaMessage.

Returns

The return value is of the uint32_t type. If the operation is successful, HIVA_SUCCESS (value being 0) is returned. If other values are returned, the operation fails.

Usage

This interface is invoked through the Publisher object. Before publishing, ensure that Topic has been declared through the CreatePublisher interface.

Precautions

  • Non-reentrant, synchronous interface.
  • Multiple threads are not allowed to publish data at the same time.
  • In SHM communication mode, the message size cannot exceed 30000000 bytes.
  • When the uint32_t OpenHiva::Publisher::Publish(const HivaMessage &message) interface is used, the message type must be inherited from HivaMessage, and static interfaces such as GetMessageType and GetMd5Sum must be implemented.