S3FC project page | S3FC home page |
#include <s3_message.h>
Inheritance diagram for s3_post_office_switch:
Public Methods | |
s3_post_office_switch (int n_port) | |
Construct an instance with the specified port number, and immediately start accepting connections. More... | |
virtual | ~s3_post_office_switch () |
virtual void | main_loop () |
Main event loop: poll the incoming transport queue for new packets. More... | |
Protected Methods | |
bool | add_dst (const std::string &dst, client_id_t client, bool is_group) |
Implement the add_dst operation. More... | |
bool | remove_dst (const std::string &dst, client_id_t client, bool is_group) |
Implement the remove_dst operation. More... | |
void | remove_client (client_id_t client) |
Remove the specified client from all client lists. More... | |
void | reply_success (const s3_txport_data< s3_message > &packet) |
Send a "success" reply in response to a message. More... | |
void | reply_failure (const s3_txport_data< s3_message > &packet) |
Send a "failure" reply in response to a message. More... | |
void | forward_msg (const s3_message &msg, const client_id_t client) |
Forward a message to a client. More... | |
void | log_msg (const std::string &where, const std::string &what) |
Log a message. More... | |
std::string | get_next_message_id () |
Return the next message id in the sequence. More... | |
void | handle_transport_events () |
Handle all the pending transport events. More... | |
Private Types | |
typedef s3_txport_client_id | client_id_t |
Type of thing used to identify connected clients. More... | |
typedef s3_fifo_queue< s3_txport_data< s3_message > > | queue_t |
Private Attributes | |
s3_txport_tcp< s3_message > * | conn |
Physical (TCP/IP) connection endpoint that maintains a client connection list.. More... | |
txp_event_queuer | txp_event_queuer |
Event handler that pushes transport events into the event queue. More... | |
std::map< std::string, dst_data > | dst_map |
Map from destination (strings) to clients id and type. More... | |
int | seq_nr |
Sequence count used to generate message IDs. More... | |
s3_semaphore | started |
Semaphore used to synchronise startup. More... | |
Friends | |
struct | dst_data |
The TCP/IP network link is implemented by a s3_txport_tcp<s3_message>
instance operating as a server (i.e. listening).
Definition at line 908 of file s3_message.h.
|
Type of thing used to identify connected clients. We use the type that is supplied by the transport. Definition at line 940 of file s3_message.h. Referenced by main_loop. |
|
Definition at line 958 of file s3_message.h. |
|
Construct an instance with the specified port number, and immediately start accepting connections. Only return once the switch is up and running.
Definition at line 1096 of file s3_message.cc. References conn, s3_txport_tcp< s3_message >::listen, s3_txport_tcp< s3_message >::listening, seq_nr, s3_thread_base::start, started, s3_event_dispatcher< s3_txport_event >::subscribe_handler, txp_event_queuer, and s3_semaphore::wait. |
|
Definition at line 1128 of file s3_message.cc. References conn, s3_thread_base::is_running, s3_thread_base::request_terminate, s3_txport_tcp< s3_message >::stop, and s3_thread_base::wait_on_exit. |
|
Implement the
Definition at line 1324 of file s3_message.cc. References dst_data, dst_map, and log_msg. Referenced by main_loop. |
|
Forward a message to a client.
Definition at line 1487 of file s3_message.cc. References conn, s3_message::get_debug_str, s3_txport_tcp< s3_message >::get_tx_queue, and S3FC_DBG. Referenced by main_loop, reply_failure, and reply_success. |
|
Return the next message id in the sequence.
Definition at line 1506 of file s3_message.cc. References seq_nr. Referenced by reply_failure, and reply_success. |
|
Handle all the pending transport events.
Definition at line 1514 of file s3_message.cc. References s3_txport_event::disconnect, s3_post_office_switch::txp_event_queuer::ev_queue, s3_txport_event::event, s3_txport_event::id, remove_client, and txp_event_queuer. Referenced by main_loop. |
|
Log a message.
Definition at line 1498 of file s3_message.cc. Referenced by add_dst, main_loop, and remove_dst. |
|
Main event loop: poll the incoming transport queue for new packets. A received packet is forwarded to all connections, except the one on which it originated. Implements s3_thread_base. Definition at line 1140 of file s3_message.cc. References add_dst, client_id_t, conn, s3_message::CONTROL, s3_txport_data::data, s3_periodic_notifier::disable, dst_map, s3_fifo_queue< s3_txport_data< s3_message > >::empty, s3_periodic_notifier::enable, s3_post_office_switch::txp_event_queuer::ev_queue, forward_msg, s3_txport_data::get_id, s3_txport_tcp< s3_message >::get_rx_queue, handle_transport_events, s3_txport_tcp< s3_message >::listening, s3_thread_base::lock_state, log_msg, s3_semaphore::post, remove_dst, reply_failure, reply_success, S3FC_DBG, started, s3_conversion::string_to_vec_string, s3_periodic_notifier::subscribe, s3_thread_base::test_terminate, txp_event_queuer, s3_thread_base::unlock_state, s3_periodic_notifier::unsubscribe, and s3_semaphore::wait. |
|
Remove the specified client from all client lists. If this leaves the client list of destination empty, the destination is removed from the destination type.
Definition at line 1434 of file s3_message.cc. References dst_map. Referenced by handle_transport_events. |
|
Implement the
Definition at line 1380 of file s3_message.cc. References dst_map, and log_msg. Referenced by main_loop. |
|
Send a "failure" reply in response to a message.
Definition at line 1476 of file s3_message.cc. References s3_txport_data::data, forward_msg, s3_txport_data::get_id, and get_next_message_id. Referenced by main_loop. |
|
Send a "success" reply in response to a message.
Definition at line 1464 of file s3_message.cc. References s3_txport_data::data, forward_msg, s3_txport_data::get_id, and get_next_message_id. Referenced by main_loop. |
|
Definition at line 943 of file s3_message.h. Referenced by add_dst. |
|
Physical (TCP/IP) connection endpoint that maintains a client connection list..
Definition at line 966 of file s3_message.h. Referenced by forward_msg, main_loop, s3_post_office_switch, and ~s3_post_office_switch. |
|
Map from destination (strings) to clients id and type. This is the destination registry. Packets can only be routed to destinations that appear in this map. Group destinations can have many clients, but individual destinations may only have a single client. This control is implemented in add_dst() and remove_dst(). This doesn't require a separate lock as in the case of the post_office, as only a single thread access it at any given time. Definition at line 981 of file s3_message.h. Referenced by add_dst, main_loop, remove_client, and remove_dst. |
|
Sequence count used to generate message IDs.
Definition at line 985 of file s3_message.h. Referenced by get_next_message_id, and s3_post_office_switch. |
|
Semaphore used to synchronise startup.
Reimplemented from s3_thread_base. Definition at line 989 of file s3_message.h. Referenced by main_loop, and s3_post_office_switch. |
|
Event handler that pushes transport events into the event queue.
Definition at line 971 of file s3_message.h. Referenced by handle_transport_events, main_loop, and s3_post_office_switch. |
Send comments to: s3fc@stonethree.com |
|