OpenHiva::Node::CreatePublisher

Description

Creates a publisher.

Prototype

template <typename M> std::shared_ptr<OpenHiva::Publisher> OpenHiva::Node::CreatePublisher(const std::string &topicName, const TopicOptions &topicOptions = TopicOptions())

Parameters

Parameter

Input/Output

Description

topicName

Input

Name of the topic to be published. The value must contain less than 128 bytes.

topicOptions

Input

Parameters for creating a publisher. For details, see OpenHiva::TopicOptions.

Returns

The OpenHiva::Publisher object is returned, which can be used to publish messages.

Usage

None

Precautions

  • Non-reentrant, synchronous interface.
  • A topic can have only one OpenHiva::Publisher. The CreatePublisher interface cannot be called repeatedly for the same topic.
  • This interface can be invoked only after OpenHiva::Init is executed. It is invoked through OpenHiva::Node.
  • M indicates the message type, which must be a subclass of HivaMessage.
  • The message types of the same topic registered by CreatePublisher and CreateSubscriber must be the same.
  • The number of Topic cannot exceed 500. The number of CreatePublisher and CreateSubscriber in the entire system cannot exceed 2048.
  • The length of TopicName cannot exceed 128 bytes. The first character must be a letter or slash (/), and the other characters must be letters, digits, slashes (/), and underscores (_).