CAF  0.17.3
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
caf::io::basp::instance Class Reference

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

#include <instance.hpp>

Classes

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

Public Types

using payload_writer = callback< error_code< sec >(binary_serializer &)>
 Describes a function object responsible for writing the payload for a BASP message.
 
using removed_published_actor = callback< error_code< sec >(const strong_actor_ptr &, uint16_t)>
 Describes a callback function object for remove_published_actor.
 
using published_actor = std::pair< strong_actor_ptr, std::set< std::string > >
 Stores the address of a published actor along with its publicly visible messaging interface.
 
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 (execution_unit *ctx, 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 handle_heartbeat (execution_unit *ctx)
 Sends heartbeat messages to all valid nodes those are directly connected.
 
optional< 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 (execution_unit *ctx, 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, strong_actor_ptr 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.
 
bool dispatch (execution_unit *ctx, const strong_actor_ptr &sender, const std::vector< strong_actor_ptr > &forwarding_stack, const node_id &dest_node, uint64_t dest_actor, uint8_t flags, message_id mid, const message &msg)
 Returns true if a path to destination existed, false otherwise.
 
proxy_registryproxies ()
 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.
 
void write_server_handshake (execution_unit *ctx, byte_buffer &out_buf, optional< uint16_t > port)
 Writes the server handshake containing the information of the actor published at port to buf. More...
 
void write_client_handshake (execution_unit *ctx, byte_buffer &buf)
 Writes the client handshake to buf.
 
void write_monitor_message (execution_unit *ctx, byte_buffer &buf, const node_id &dest_node, actor_id aid)
 Writes an announce_proxy to buf.
 
void write_down_message (execution_unit *ctx, byte_buffer &buf, const node_id &dest_node, actor_id aid, const error &rsn)
 Writes a kill_proxy to buf.
 
void write_heartbeat (execution_unit *ctx, byte_buffer &buf)
 Writes a heartbeat to buf.
 
const node_idthis_node () const
 
detail::worker_hub< worker > & hub ()
 
message_queuequeue ()
 
actor_systemsystem ()
 
const actor_system_configconfig ()
 
connection_state handle (execution_unit *ctx, connection_handle hdl, header &hdr, byte_buffer *payload)
 

Static Public Member Functions

static void write (execution_unit *ctx, byte_buffer &buf, header &hdr, payload_writer *pw=nullptr)
 Writes a header followed by its payload to storage.
 

Detailed Description

Describes a protocol instance managing multiple connections.

Member Function Documentation

◆ write()

void caf::io::basp::instance::write ( execution_unit ctx,
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.

◆ write_server_handshake()

void caf::io::basp::instance::write_server_handshake ( execution_unit ctx,
byte_buffer out_buf,
optional< 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: