ZIO
Python and C++ interface to ZeroMQ and Zyre
Public Types | Public Member Functions | List of all members
zio::Peer Class Reference

Peer at the network to discover peers and advertise self. More...

#include <peer.hpp>

Public Types

typedef int timeout_t
 A timeout in milliseconds. More...
 

Public Member Functions

 ~Peer ()
 
 Peer (const nickname_t &nickname, const headerset_t &headers={}, bool verbose=false)
 Advertise own nickname and headers. More...
 
void set_verbose (bool verbose=true)
 Turn on verbose debugging of the underlying Zyre actor. More...
 
const nickname_t nickname ()
 Get our nickname. More...
 
bool poll (timeout_t timeout=0)
 Poll the network for updates, timeout in msec. More...
 
void drain ()
 Continually poll until all queued zyre messages are processed. More...
 
std::vector< uuid_twaitfor (const nickname_t &nickname, timeout_t timeout=-1)
 Wait for a peer of a given nickname to be discovered. More...
 
void waituntil (const uuid_t &uuid, timeout_t timeout=-1)
 Wait until a specific peer has left the network. More...
 
const peerset_tpeers ()
 Return known peers as map from UUID to nickname. More...
 
peer_info_t peer_info (const uuid_t &uuid)
 Return info about peer. If unknown, return default structure. More...
 
bool isknown (const uuid_t &uuid)
 Return true if peer has been seen ENTER the network and not yet seen to EXIT. More...
 
std::vector< uuid_tnickmatch (const nickname_t &nick)
 Return all UUIDs with matching nickname. More...
 

Detailed Description

Peer at the network to discover peers and advertise self.

This is a C++ interface to ZeroMQ's Zyre which adds some memory of peers seen and ways to iterate on their Zyre headers.

Definition at line 44 of file peer.hpp.

Member Typedef Documentation

◆ timeout_t

typedef int zio::Peer::timeout_t

A timeout in milliseconds.

Definition at line 47 of file peer.hpp.

Constructor & Destructor Documentation

◆ ~Peer()

zio::Peer::~Peer ( )

Definition at line 43 of file peer.cpp.

◆ Peer()

zio::Peer::Peer ( const nickname_t nickname,
const headerset_t headers = {},
bool  verbose = false 
)

Advertise own nickname and headers.

Definition at line 17 of file peer.cpp.

Member Function Documentation

◆ drain()

void zio::Peer::drain ( )

Continually poll until all queued zyre messages are processed.

Definition at line 177 of file peer.cpp.

◆ isknown()

bool zio::Peer::isknown ( const uuid_t uuid)

Return true if peer has been seen ENTER the network and not yet seen to EXIT.

Definition at line 182 of file peer.cpp.

◆ nickmatch()

std::vector< zio::uuid_t > zio::Peer::nickmatch ( const nickname_t nick)

Return all UUIDs with matching nickname.

Definition at line 132 of file peer.cpp.

◆ nickname()

const nickname_t zio::Peer::nickname ( )
inline

Get our nickname.

Definition at line 60 of file peer.hpp.

◆ peer_info()

zio::peer_info_t zio::Peer::peer_info ( const uuid_t uuid)

Return info about peer. If unknown, return default structure.

Definition at line 194 of file peer.cpp.

◆ peers()

const zio::peerset_t & zio::Peer::peers ( )

Return known peers as map from UUID to nickname.

This will return new values on subsequent calls as peers enter and exit the network.

Definition at line 189 of file peer.cpp.

◆ poll()

bool zio::Peer::poll ( timeout_t  timeout = 0)

Poll the network for updates, timeout in msec.

Return true if an even was from the nework processed. Use timeout=-1 to wait until an event if received.

Definition at line 50 of file peer.cpp.

◆ set_verbose()

void zio::Peer::set_verbose ( bool  verbose = true)

Turn on verbose debugging of the underlying Zyre actor.

Definition at line 206 of file peer.cpp.

◆ waitfor()

std::vector< zio::uuid_t > zio::Peer::waitfor ( const nickname_t nickname,
timeout_t  timeout = -1 
)

Wait for a peer of a given nickname to be discovered.

Return UUID if found, empty string if timeout occurs. Note, multiple peers may share the same nickname.

Definition at line 148 of file peer.cpp.

◆ waituntil()

void zio::Peer::waituntil ( const uuid_t uuid,
timeout_t  timeout = -1 
)

Wait until a specific peer has left the network.

If it is already gone, return immediately or in any case no longer than the timeout.


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