libcaf  0.15.3
Public Types | Public Member Functions | Related Functions | List of all members
caf::io::hook Class Reference

Interface to define hooks into the IO layer. More...

#include <hook.hpp>

Public Types

enum  event_type {
  message_received,
  message_sent,
  message_forwarded,
  message_sending_failed,
  message_forwarding_failed,
  actor_published,
  new_remote_actor,
  new_connection_established,
  new_route_added,
  connection_lost,
  route_lost,
  invalid_message_received,
  before_shutdown
}
 All possible events for IO hooks.
 

Public Member Functions

 hook (actor_system &sys)
 
virtual void message_received_cb (const node_id &source, const strong_actor_ptr &from, const strong_actor_ptr &dest, message_id mid, const message &msg)
 Called whenever a message has arrived via the network.
 
virtual void message_sent_cb (const strong_actor_ptr &from, const node_id &hop, const strong_actor_ptr &dest, message_id mid, const message &payload)
 Called whenever a message has been sent to the network. More...
 
virtual void message_sending_failed_cb (const strong_actor_ptr &from, const strong_actor_ptr &dest, message_id mid, const message &payload)
 Called whenever no route for sending a message exists.
 
virtual void message_forwarded_cb (const basp::header &hdr, const std::vector< char > *payload)
 Called whenever a message is forwarded to a different node.
 
virtual void message_forwarding_failed_cb (const basp::header &hdr, const std::vector< char > *payload)
 Called whenever no route for a forwarding request exists.
 
virtual void actor_published_cb (const strong_actor_ptr &addr, const std::set< std::string > &ifs, uint16_t port)
 Called whenever an actor has been published.
 
virtual void new_remote_actor_cb (const strong_actor_ptr &addr)
 Called whenever a new remote actor appeared.
 
virtual void new_connection_established_cb (const node_id &node)
 Called whenever a handshake via a direct TCP connection succeeded.
 
virtual void new_route_added_cb (const node_id &via, const node_id &node)
 Called whenever a message from or to a yet unknown node was received. More...
 
virtual void connection_lost_cb (const node_id &dest)
 Called whenever a direct connection was lost.
 
virtual void route_lost_cb (const node_id &hop, const node_id &dest)
 Called whenever a route became unavailable. More...
 
virtual void invalid_message_received_cb (const node_id &source, const strong_actor_ptr &sender, actor_id invalid_dest, message_id mid, const message &msg)
 Called whenever a message was discarded because a remote node tried to send a message to an actor ID that could not be found in the registry. More...
 
virtual void before_shutdown_cb ()
 Called before middleman shuts down.
 
template<event_type Event, typename... Ts>
void handle (Ts &&...ts)
 Handles an event by invoking the associated callback.
 
actor_systemsystem () const
 

Related Functions

(Note that these are not member functions.)

using hook_uptr = std::unique_ptr< hook >
 

Detailed Description

Interface to define hooks into the IO layer.

Member Function Documentation

virtual void caf::io::hook::invalid_message_received_cb ( const node_id source,
const strong_actor_ptr sender,
actor_id  invalid_dest,
message_id  mid,
const message msg 
)
virtual

Called whenever a message was discarded because a remote node tried to send a message to an actor ID that could not be found in the registry.

virtual void caf::io::hook::message_sent_cb ( const strong_actor_ptr from,
const node_id hop,
const strong_actor_ptr dest,
message_id  mid,
const message payload 
)
virtual

Called whenever a message has been sent to the network.

Parameters
fromThe address of the sending actor.
hopThe node in the network we've sent the message to.
destThe address of the receiving actor. Note that the node ID of dest can differ from hop in case we don't have a direct connection to dest_node.
midThe ID of the message.
payloadThe message we've sent.
virtual void caf::io::hook::new_route_added_cb ( const node_id via,
const node_id node 
)
virtual

Called whenever a message from or to a yet unknown node was received.

Parameters
viaThe node that has sent us the message.
nodeThe newly added entry to the routing table.
virtual void caf::io::hook::route_lost_cb ( const node_id hop,
const node_id dest 
)
virtual

Called whenever a route became unavailable.

Parameters
hopThe node that was either disconnected or lost a connection itself.
destThe node that is no longer reachable via hop.

Friends And Related Function Documentation

using hook_uptr = std::unique_ptr<hook>
related

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