MVSIM
Lightweight simulator for 2.5D vehicles and robots
Classes | Functions | Variables
Mvsim_comms_module

Classes

class  mvsim::Client
 
class  mvsim::UnexpectedMessageException
 
struct  mvsim::overloaded< Ts >
 
class  mvsim::Server
 
class  mvsim::SocketMonitor
 

Functions

void mvsim::sendMessage (const google::protobuf::MessageLite &m, zmq::socket_t &socket)
 
zmq::message_t mvsim::receiveMessage (zmq::socket_t &s)
 
void mvsim::parseMessage (const zmq::message_t &msg, google::protobuf::MessageLite &out)
 
std::string mvsim::get_zmq_endpoint (const zmq::socket_t &s)
 
template<typename variant_t >
variant_t mvsim::parseMessageVariant (const zmq::message_t &msg)
 
template<class... Ts>
 mvsim::overloaded (Ts...) -> overloaded< Ts... >
 

Variables

constexpr unsigned int mvsim::MVSIM_PORTNO_MAIN_REP = 23700
 

Detailed Description

Function Documentation

◆ overloaded()

template<class... Ts>
mvsim::overloaded ( Ts...  ) -> overloaded< Ts... >

◆ parseMessage()

void mvsim::parseMessage ( const zmq::message_t &  msg,
google::protobuf::MessageLite &  out 
)

Parses a ZMQ message received as sent by sendMessage(), and decodes it into the provided google::protobuf message. Use this signature when the expected type of the received message is known before hand.

Exceptions
std::runtime_errorIf the message type does not match with out.

◆ parseMessageVariant()

template<typename variant_t >
variant_t mvsim::parseMessageVariant ( const zmq::message_t &  msg)

Parses a ZMQ message into one of a set of possible protobuf message types, passed as a std::variant<...>.

Exceptions
UnexpectedMessageExceptionIf none of the types coincide.

◆ receiveMessage()

zmq::message_t mvsim::receiveMessage ( zmq::socket_t &  s)

Receives a message from the socket.

◆ sendMessage()

void mvsim::sendMessage ( const google::protobuf::MessageLite &  m,
zmq::socket_t &  socket 
)

Sends a ZMQ message comprising:

  • std::string with the protobuf message type name.
  • std::string with the binary serialization of the message itself.