libcaf  0.14.4
Classes | Public Types | Public Member Functions | List of all members
caf::io::basp::instance Class Reference

Describes a protocol instance managing multiple connections. More...

#include <basp.hpp>

Classes

class  callee
 Provides a callback-based interface for certain BASP events. More...
 

Public Types

using payload_writer = callback< serializer & >
 Describes a function object responsible for writing the payload for a BASP message. More...
 
using removed_published_actor = callback< const actor_addr &, uint16_t >
 Describes a callback function object for remove_published_actor.
 
using published_actor = std::pair< actor_addr, std::set< std::string >>
 Stores the address of a published actor along with its publicly visible messaging interface. More...
 
using published_actor_map = std::unordered_map< uint16_t, published_actor >
 Maps ports to addresses and interfaces of published actors.
 

Public Member Functions

 instance (abstract_broker *parent, callee &lstnr)
 
connection_state handle (const new_data_msg &dm, header &hdr, bool is_payload)
 Handles received data and returns a config for receiving the next data or none if an error occured. More...
 
void handle (const connection_closed_msg &msg)
 Handles connection shutdowns.
 
void handle_node_shutdown (const node_id &affected_node)
 Handles failure or shutdown of a single node. More...
 
maybe< routing_table::routelookup (const node_id &target)
 Returns a route to target or none on error.
 
void flush (const routing_table::route &path)
 Flushes the underlying buffer of path.
 
void write (const routing_table::route &r, header &hdr, payload_writer *writer=nullptr)
 Sends a BASP message and implicitly flushes the output buffer of r. More...
 
void add_published_actor (uint16_t port, actor_addr published_actor, std::set< std::string > published_interface)
 Adds a new actor to the map of published actors.
 
size_t remove_published_actor (uint16_t port, removed_published_actor *cb=nullptr)
 Removes the actor currently assigned to port.
 
size_t remove_published_actor (const actor_addr &whom, uint16_t port, removed_published_actor *cb=nullptr)
 Removes whom if it is still assigned to port or from all of its current ports if port == 0. More...
 
bool dispatch (const actor_addr &sender, const actor_addr &receiver, message_id mid, const message &msg)
 Returns true if a path to destination existed, false otherwise.
 
actor_namespaceget_namespace ()
 Returns the actor namespace associated to this BASP protocol instance.
 
routing_tabletbl ()
 Returns the routing table of this BASP instance.
 
const published_actor_mappublished_actors () const
 Returns the current mapping of ports to addresses and interfaces of published actors. More...
 
void write (buffer_type &storage, message_type operation, uint32_t *payload_len, uint64_t operation_data, const node_id &source_node, const node_id &dest_node, actor_id source_actor, actor_id dest_actor, payload_writer *writer=nullptr)
 Writes a header (build from the arguments) followed by its payload to storage. More...
 
void write (buffer_type &storage, header &hdr, payload_writer *writer=nullptr)
 Writes a header followed by its payload to storage.
 
void write_server_handshake (buffer_type &buf, maybe< uint16_t > port)
 Writes the server handshake containing the information of the actor published at port to buf. More...
 
void write_client_handshake (buffer_type &buf, const node_id &remote_side)
 Writes the client handshake to buf.
 
void write_dispatch_error (buffer_type &buf, const node_id &source_node, const node_id &dest_node, error error_code, const header &original_hdr, const buffer_type *payload)
 Writes a dispatch_error to buf.
 
void write_kill_proxy_instance (buffer_type &buf, const node_id &dest_node, actor_id aid, uint32_t rsn)
 Writes a kill_proxy_instance to buf.
 
const node_idthis_node () const
 
template<hook::event_type Event, typename... Ts>
void notify (Ts &&...xs)
 Invokes the callback(s) associated with given event.
 

Detailed Description

Describes a protocol instance managing multiple connections.

Member Typedef Documentation

Describes a function object responsible for writing the payload for a BASP message.

using caf::io::basp::instance::published_actor = std::pair<actor_addr, std::set<std::string>>

Stores the address of a published actor along with its publicly visible messaging interface.

Member Function Documentation

connection_state caf::io::basp::instance::handle ( const new_data_msg dm,
header hdr,
bool  is_payload 
)

Handles received data and returns a config for receiving the next data or none if an error occured.

void caf::io::basp::instance::handle_node_shutdown ( const node_id affected_node)

Handles failure or shutdown of a single node.

This function purges all routes to affected_node from the routing table.

const published_actor_map& caf::io::basp::instance::published_actors ( ) const

Returns the current mapping of ports to addresses and interfaces of published actors.

size_t caf::io::basp::instance::remove_published_actor ( const actor_addr whom,
uint16_t  port,
removed_published_actor cb = nullptr 
)

Removes whom if it is still assigned to port or from all of its current ports if port == 0.

void caf::io::basp::instance::write ( const routing_table::route r,
header hdr,
payload_writer writer = nullptr 
)

Sends a BASP message and implicitly flushes the output buffer of r.

This function will update hdr.payload_len if a payload was written.

void caf::io::basp::instance::write ( buffer_type storage,
message_type  operation,
uint32_t *  payload_len,
uint64_t  operation_data,
const node_id source_node,
const node_id dest_node,
actor_id  source_actor,
actor_id  dest_actor,
payload_writer writer = nullptr 
)

Writes a header (build from the arguments) followed by its payload to storage.

void caf::io::basp::instance::write_server_handshake ( buffer_type buf,
maybe< uint16_t >  port 
)

Writes the server handshake containing the information of the actor published at port to buf.

If port == none or if no actor is published at this port then a standard handshake is written (e.g. used when establishing direct connections on-the-fly).


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