Turi Create  4.0
turi::nanosockets::subscribe_socket Class Reference

#include <core/system/nanosockets/subscribe_socket.hpp>

Public Member Functions

 subscribe_socket (callback_type callback)
 
void close ()
 
void connect (std::string endpoint)
 
void disconnect (std::string endpoint)
 
void subscribe (std::string topic)
 
void unsubscribe (std::string topic)
 

Detailed Description

Constructs a subscribe socket.

The subscribe socket binds to at least one endpoint bound by a publish socket (publish_socket). Everything the publish socket publishes will be received by the callback. You can register interest in prefix matches of the message.

void callback(const std::string& message) {
std::cout << message;
}
subscribe_socket subsock(callback);
subsock.connect("ipc:///tmp/publish");
subsock.subscribe("ABC"); // only received messages beginning with ABC

Definition at line 37 of file subscribe_socket.hpp.

Constructor & Destructor Documentation

◆ subscribe_socket()

turi::nanosockets::subscribe_socket::subscribe_socket ( callback_type  callback)

Constructs a subscribe socket.

Parameters
callbackThe function used to process replies.

keyval can be NULL in which case all "connect/disconnect" calls must refer to a ZeroMQ endpoints.

Member Function Documentation

◆ close()

void turi::nanosockets::subscribe_socket::close ( )

Closes the socket. Once closed. It cannot be opened again

◆ connect()

void turi::nanosockets::subscribe_socket::connect ( std::string  endpoint)

the argument must be a Nanomsg endpoint to connect to.

◆ disconnect()

void turi::nanosockets::subscribe_socket::disconnect ( std::string  endpoint)

Disconnects from a given endpoint.

◆ subscribe()

void turi::nanosockets::subscribe_socket::subscribe ( std::string  topic)

Subscribes to a topic. A topic is any message prefix. Only messages with prefix matching the topic will be received.

◆ unsubscribe()

void turi::nanosockets::subscribe_socket::unsubscribe ( std::string  topic)

Unsubscribes from a topic. A topic is any message prefix. See


The documentation for this class was generated from the following file: