BlueZero (BØ)
Middleware for distributed applications
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
b0::ServiceServer Class Reference

The service server class. More...

#include <b0/service_server.h>

Inheritance diagram for b0::ServiceServer:
b0::Socket b0::logger::LogInterface

Public Member Functions

 ServiceServer (Node *node, std::string service_name, boost::function< void(const std::string &, std::string &)> callback=0, bool managed=true, bool notify_graph=true)
 Construct an ServiceServer child of the specified Node, optionally using a boost::function as a callback.
 
template<class TNode >
 ServiceServer (TNode *node, std::string service_name, void(TNode::*callbackMethod)(const std::string &, std::string &), bool managed=true, bool notify_graph=true)
 Construct a ServiceServer child of a specific Node, using a method (of the Node subclass) as callback.
 
template<class T >
 ServiceServer (Node *node, std::string service_name, void(T::*callbackMethod)(const std::string &, std::string &), T *callbackObject, bool managed=true, bool notify_graph=true)
 Construct a ServiceServer child of a specific Node, using a method as callback.
 
virtual ~ServiceServer ()
 ServiceServer destructor.
 
void log (LogLevel level, std::string message) const override
 Log a message using node's logger, prepending this service server informations.
 
virtual void init () override
 Perform initialization and optionally send graph notify.
 
virtual void cleanup () override
 Perform cleanup and optionally send graph notify.
 
virtual void spinOnce () override
 Poll and read incoming messages, and dispatch them (called by b0::Node::spinOnce())
 
std::string getServiceName ()
 Return the name of this server's service.
 
virtual void bind (std::string address)
 Bind to an additional address.
 
- Public Member Functions inherited from b0::Socket
 Socket (Node *node, int type, std::string name, bool managed=true)
 Construct a Socket.
 
virtual ~Socket ()
 Socket destructor.
 
void setHasHeader (bool has_header)
 Set the has_header_ flag which specifies if this socket require a message part with the address (usually for publish/subscribe pattern).
 
void log (LogLevel level, std::string message) const override
 Log a message to the default logger of this node.
 
void setRemoteAddress (std::string addr)
 Set the remote address the socket will connect to.
 
std::string getName () const
 Return the name of the socket bus.
 
NodegetNode () const
 Return the node owning this socket.
 
bool matchesPattern (const std::string &pattern) const
 Check if this socket name matches the specified pattern. More...
 
virtual void readRaw (std::string &msg)
 Read a raw payload from the underlying ZeroMQ socket.
 
virtual void readRaw (std::string &msg, std::string &type)
 Read a raw payload with type from the underlying ZeroMQ socket.
 
virtual bool poll (long timeout=0)
 Poll for messages. If timeout is 0 return immediately, otherwise wait for the specified amount of milliseconds.
 
virtual void writeRaw (const std::string &msg, const std::string &type="")
 Write a raw payload.
 
void setCompression (std::string algorithm, int level=-1)
 Set compression algorithm and level. More...
 
int getReadTimeout () const
 (low-level socket option) Get read timeout (in milliseconds, -1 for no timeout)
 
void setReadTimeout (int timeout)
 (low-level socket option) Set read timeout (in milliseconds, -1 for no timeout)
 
int getWriteTimeout () const
 (low-level socket option) Get write timeout (in milliseconds, -1 for no timeout)
 
void setWriteTimeout (int timeout)
 (low-level socket option) Set write timeout (in milliseconds, -1 for no timeout)
 
int getLingerPeriod () const
 (low-level socket option) Get linger period (in milliseconds, -1 for no timeout)
 
void setLingerPeriod (int period)
 (low-level socket option) Set linger period (in milliseconds, -1 for no timeout)
 
int getBacklog () const
 (low-level socket option) Get backlog
 
void setBacklog (int backlog)
 (low-level socket option) Set backlog
 
bool getImmediate () const
 (low-level socket option) Get immediate flag
 
void setImmediate (bool immediate)
 (low-level socket option) Set immediate flag
 
bool getConflate () const
 (low-level socket option) Get conflate flag
 
void setConflate (bool conflate)
 (low-level socket option) Set conflate flag
 
int getReadHWM () const
 (low-level socket option) Get read high-water-mark
 
void setReadHWM (int n)
 (low-level socket option) Set read high-water-mark
 
int getWriteHWM () const
 (low-level socket option) Get write high-water-mark
 
void setWriteHWM (int n)
 (low-level socket option) Set write high-water-mark
 
- Public Member Functions inherited from b0::logger::LogInterface
template<typename... Arguments>
void log (LogLevel level, std::string const &fmt, Arguments &&... args) const
 Log a message using a format string.
 

Protected Member Functions

virtual void bind ()
 Bind socket to the address.
 
virtual void unbind ()
 Unbind socket from the address.
 
virtual void announce ()
 Announce service to resolver.
 
- Protected Member Functions inherited from b0::Socket
void connect (std::string const &addr)
 Wrapper to zmq::socket_t::connect.
 
void disconnect (std::string const &addr)
 Wrapper to zmq::socket_t::disconnect.
 
void bind (std::string const &addr)
 Wrapper to zmq::socket_t::bind.
 
void unbind (std::string const &addr)
 Wrapper to zmq::socket_t::unbind.
 
void setsockopt (int option, const void *optval, size_t optvallen)
 Wrapper to zmq::socket_t::setsockopt.
 
void getsockopt (int option, void *optval, size_t *optvallen) const
 Wrapper to zmq::socket_t::getsockopt.
 
void setIntOption (int option, int value)
 High level wrapper for setsockopt.
 
int getIntOption (int option) const
 High level wrapper for getsockopt.
 

Protected Attributes

std::string bind_addr_
 The ZeroMQ address to bind the service socket on.
 
const bool notify_graph_
 If false this socket will not send announcement to resolv (i.e. it will be "invisible")
 
boost::function< void(const std::string &, std::string &)> callback_
 Callback which will be called when a new message is read from the socket.
 
- Protected Attributes inherited from b0::Socket
Nodenode_
 The Node owning this Socket.
 
std::string name_
 This socket bus name.
 
bool has_header_
 True if the payload has a header part (i.e. More...
 
const bool managed_
 True if this socket is managed (init(), cleanup() are called by the owner Node)
 
std::string remote_addr_
 The address of the ZeroMQ socket to connect to (will skip name resolution if given)
 

Additional Inherited Members

- Public Types inherited from b0::logger::LogInterface
enum  LogLevel {
  trace = 0, debug = 10, info = 20, warn = 30,
  error = 40, fatal = 50
}
 

Detailed Description

The service server class.

This class wraps a REP socket. It will automatically announce the socket name to resolver.

See also
b0::ServiceClient, b0::ServiceServer
Examples:
server_node.cpp, and server_node_object.cpp.

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