Server client instance. More...

#include <senf/Utils/Console/Server.hh>

Inheritance diagram for senf::console::Client:

Public Types

typedef Server::ServerHandle::ClientHandle ClientHandle
 
- Public Types inherited from senf::intrusive_refcount_base
typedef unsigned refcount_t
 
- Public Types inherited from senf::log::Target
enum  action_t
 
typedef RIB::const_iterator iterator
 
typedef RIB::size_type size_type
 

Public Member Functions

 ~Client ()
 
void stop ()
 Stop the client. More...
 
std::string const & name () const
 Get name of the client instance. More...
 
ClientHandle handle () const
 Get the client's network socket handle. More...
 
std::ostream & stream ()
 Get client's output stream. More...
 
std::string promptString () const
 Get the prompt string. More...
 
DirectoryNoderoot () const
 Get configured root node. More...
 
DirectoryNodecwd () const
 Get current directory. More...
 
Server::Mode mode () const
 Get operation mode. More...
 
void write (std::string const &data) const
 Write data to network socket. More...
 
std::string const & backtrace () const
 Get backtrace of last console error, if any. More...
 
unsigned width () const
 Get console width. More...
 
void setProperty (std::string const &key, std::string const &value)
 
std::string getProperty (std::string const &key, std::string const &defaultValue) const
 
boost::optional< std::string > getProperty (std::string const &key) const
 
- Public Member Functions inherited from senf::intrusive_refcount_base
virtual ~intrusive_refcount_base ()
 
refcount_t refcount () const
 
bool is_shared () const
 
- Public Member Functions inherited from senf::log::IOStreamTarget
std::ostream & stream () const
 
void stream (std::ostream &newos)
 
 IOStreamTarget (std::string const &name, std::ostream &os)
 
- Public Member Functions inherited from senf::log::Target
iterator begin () const
 
iterator end () const
 
RoutingEntry const & operator[] (size_type i) const
 
size_type size () const
 
bool empty () const
 
void flush ()
 
senf::console::ScopedDirectoryconsoleDir ()
 
std::ostream & operator<< (std::ostream &os, Target::action_t const &action)
 
 Target (std::string const &name)
 
virtual ~Target ()
 
void route (action_t action=ACCEPT, int index=-1)
 
void route (std::string const &stream, std::string const &area="", unsigned level=NONE::value, action_t action=ACCEPT, int index=-1)
 
void unroute (action_t action=ACCEPT)
 
void unroute (std::string const &stream, std::string const &area="", unsigned level=NONE::value, action_t action=ACCEPT)
 
void unroute (int index=-1)
 

Static Public Member Functions

static Clientget (std::ostream &os)
 Access client instance. More...
 
static unsigned getWidth (std::ostream &os, unsigned defaultWidth=0, unsigned minWidth=0)
 Get width of client console if possible. More...
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &os, Client const &client)
 Output Console Client instance as it's string representation. More...
 
std::ostream & operator<< (std::ostream &os, Client *client)
 Output Console Client instance as it's string representation. More...
 

Additional Inherited Members

- Public Attributes inherited from senf::log::Target
 ACCEPT
 
 REJECT
 
- Protected Member Functions inherited from senf::intrusive_refcount
 intrusive_refcount ()
 
- Protected Member Functions inherited from intrusive_refcount_t< intrusive_refcount >
 intrusive_refcount_t ()
 
- Protected Member Functions inherited from senf::intrusive_refcount_base
 intrusive_refcount_base ()
 
void add_ref ()
 
bool release ()
 

Detailed Description

Server client instance.

Whenever a new client connects, a new instance of this class is created. This class shows a command prompt, receives the commands, parses them and then passes (using a CommandParser) and passes the commands to an Executor instance.

Definition at line 143 of file Server.hh.

Member Typedef Documentation

◆ ClientHandle

typedef Server::ServerHandle::ClientHandle senf::console::Client::ClientHandle

Definition at line 156 of file Server.hh.

Constructor & Destructor Documentation

◆ ~Client()

senf::console::Client::~Client ( )

Member Function Documentation

◆ backtrace()

std::string const& senf::console::Client::backtrace ( ) const

Get backtrace of last console error, if any.

◆ cwd()

DirectoryNode& senf::console::Client::cwd ( ) const

Get current directory.

This is the directory, the console currently is changed into by the user of the console.

◆ get()

static Client& senf::console::Client::get ( std::ostream &  os)
static

Access client instance.

Allows to access the client instance from console command implementations. The first argument to a console command is a stream object. If this stream object belongs to a network console client, this call will return the associated Client instance reference.

Exceptions
std::bad_castif os is not associated with a Client instance.

◆ getProperty() [1/2]

std::string senf::console::Client::getProperty ( std::string const &  key,
std::string const &  defaultValue 
) const

Definition at line 498 of file Server.cc.

◆ getProperty() [2/2]

boost::optional< std::string > senf::console::Client::getProperty ( std::string const &  key) const

Definition at line 491 of file Server.cc.

◆ getWidth()

unsigned senf::console::Client::getWidth ( std::ostream &  os,
unsigned  defaultWidth = 0,
unsigned  minWidth = 0 
)
static

Get width of client console if possible.

If possible, the width of the client console attached to the stream os is returned. If this is not possible, the defaultValue will be used.

If the width obtained this way is smaller than minWidth, defaultValue will be returned instead.

Definition at line 475 of file Server.cc.

◆ handle()

ClientHandle senf::console::Client::handle ( ) const

Get the client's network socket handle.

◆ mode()

Server::Mode senf::console::Client::mode ( ) const

Get operation mode.

See also
Server::mode()

◆ name()

std::string const& senf::console::Client::name ( ) const

Get name of the client instance.

This name is used in the prompt string and is set by the server.

◆ promptString()

std::string senf::console::Client::promptString ( ) const

Get the prompt string.

◆ root()

DirectoryNode& senf::console::Client::root ( ) const

Get configured root node.

◆ setProperty()

void senf::console::Client::setProperty ( std::string const &  key,
std::string const &  value 
)

Definition at line 486 of file Server.cc.

◆ stop()

void senf::console::Client::stop ( )

Stop the client.

This will close the client socket.

◆ stream()

std::ostream& senf::console::Client::stream ( )

Get client's output stream.

Data sent to this stream is sent out over the network via the client's socket handle. Write operation is non-blocking and data may be dropped. Data is written using Client::write().

◆ width()

unsigned senf::console::Client::width ( ) const

Get console width.

If possible, this will be the width of the connected terminal, otherwise a default value (normally 80) is returned.

◆ write()

void senf::console::Client::write ( std::string const &  data) const

Write data to network socket.

The data is automatically filtered depending on the type of connection (e.g. on a telnet connection, specific bytes are quoted).

Friends And Related Function Documentation

◆ operator<<() [1/2]

std::ostream & operator<< ( std::ostream &  os,
Client const &  client 
)
related

Output Console Client instance as it's string representation.

◆ operator<<() [2/2]

std::ostream & operator<< ( std::ostream &  os,
Client client 
)
related

Output Console Client instance as it's string representation.


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