Telnet++
A C++ library for interacting with Telnet streams
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | List of all members
telnetpp::client_option Class Referenceabstract

A class that represents a Telnet option's client side. More...

#include <client_option.hpp>

Inheritance diagram for telnetpp::client_option:
telnetpp::options::echo::client telnetpp::options::mccp::client telnetpp::options::msdp::client telnetpp::options::naws::client telnetpp::options::new_environ::client telnetpp::options::subnegotiationless_client< Option > telnetpp::options::suppress_ga::client telnetpp::options::terminal_type::client

Public Types

enum  state { inactive, activating, active, deactivating }
 An enumeration of the different states in which this option can be. More...
 

Public Member Functions

telnetpp::u8 option () const
 Returns the option code.
 
void set_activatable ()
 Flags the option as remotely activatable. More...
 
std::vector< telnetpp::tokenactivate ()
 Activates the option; sends a DO negotiation.
 
std::vector< telnetpp::tokendeactivate ()
 Deactivates the option; sends a DONT negotiation.
 
bool is_active () const
 Returns true iff the option is active.
 
std::vector< telnetpp::tokennegotiate (telnetpp::u8 request)
 Makes a request of the option and returns the response from that request. More...
 
std::vector< telnetpp::tokensubnegotiate (telnetpp::u8stream const &content)
 Send a subnegotiation to the option and returns the response from that subnegotiation. More...
 

Public Attributes

boost::signals2::signal< std::vector< telnetpp::token >state new_state), token_combineron_state_changed
 A signal that you can connect to in order to detect changes in the state of the option. More...
 

Protected Member Functions

 client_option (telnetpp::u8 option)
 Constructor. More...
 

Detailed Description

A class that represents a Telnet option's client side.

That is, the side that received WILL and WONT negotiations and sends DO and DONT negotiations.

Server vs. Client
Note that the usage of client in this context may disagree with a particular option's RFC specification. The determination of what is a client and what is a server is not rigorously applies throughout the RFCs, so consider this merely an implementation detail of this library.
Usage
client_option provides a general interface to enable the implementation of the client sides of all Telnet options. There are two customization points that must be filled in before an implementation is complete:
  • the derived class must call the constructor, passing in a value that is the Option Code for the feature being implemented.
  • the derived class must implement the handle_subnegotiation function. This is called whenever data specific to the option passes through the Telnet layer.
A final third customization point is the on_state_changed signal, to which a user can connect to have functionality executed when the option changes state.
See also
https://tools.ietf.org/html/std8

Member Enumeration Documentation

An enumeration of the different states in which this option can be.

Constructor & Destructor Documentation

telnetpp::client_option::client_option ( telnetpp::u8  option)
explicitprotected

Constructor.

Parameters
optionThe Option Code of this option.

Member Function Documentation

std::vector< telnetpp::token > telnetpp::client_option::negotiate ( telnetpp::u8  request)

Makes a request of the option and returns the response from that request.

void telnetpp::client_option::set_activatable ( )

Flags the option as remotely activatable.

Allows the option to be activated by the remote end. That is, if the option receives a WILL negotiation, it will respond with a DO negotiation. An option that has not have this function called will instead respond with a DONT negotiation.

std::vector< telnetpp::token > telnetpp::client_option::subnegotiate ( telnetpp::u8stream const &  content)

Send a subnegotiation to the option and returns the response from that subnegotiation.

Member Data Documentation

boost::signals2::signal< std::vector<telnetpp::token>state new_state), token_combiner > telnetpp::client_option::on_state_changed

A signal that you can connect to in order to detect changes in the state of the option.

Usage
my_option.on_state_changed.connect(
-> std::vector<telnetpp::token>
{
// Do something with the state change
std::cout << "state is now: " << new_state << "\n";
// return some vector of tokens, or an empty vector
return {};
});
See also
telnetpp::client_option::state

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