#include "director.h" Dispatch::Dispatch(Director &dir) : d{dir} {}; // virtuals void Dispatch::server_line(const std::string &line){}; void Dispatch::server_prompt(const std::string &prompt){}; void Dispatch::client_input(const std::string &input){}; void Dispatch::to_server(const std::string &send) { d.to_server(send); } void Dispatch::to_client(const std::string &send) { d.to_client(send); } Director::Director(Session &s) : session{s} {} void Director::server_line(const std::string &line) { if (server_line_) server_line_(line); } void Director::server_prompt(const std::string &prompt) { if (server_prompt_) server_prompt_(prompt); } void Director::client_input(const std::string &input) { if (client_input_) client_input_(input); } // These would be called by the Dispatch -- // since it has direct access to us. void Director::to_server(const std::string &send) { session.to_server(send); } void Director::to_client(const std::string &send) { session.to_client(send); } void Director::set_server_line(stringFunc new_sl) { server_line_ = new_sl; } void Director::set_server_prompt(stringFunc new_sp) { server_prompt_ = new_sp; } void Director::set_client_input(stringFunc new_ci) { client_input_ = new_ci; } OldValues Director::get_state(void) { OldValues values; values.server_line = server_line_; values.server_prompt = server_prompt_; values.client_input = client_input_; values.to_client = to_client_; server_line_(nullptr); server_prompt_(nullptr); client_input_(nullptr); to_client_ = false; return values; } void Director::restore_state(OldValues v) { server_line_ = v.server_line; server_prompt_ = v.server_prompt; client_input_ = v.client_input; to_client_ = v.to_client; }