Interactive console server. More...

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

Inheritance diagram for senf::console::Server:

Public Types

enum  Mode { Automatic, Interactive, Noninteractive }
 
typedef detail::ServerHandle ServerHandle
 
- Public Types inherited from senf::intrusive_refcount_base
typedef unsigned refcount_t
 

Public Member Functions

std::string const & name () const
 Get server name. More...
 
Servername (std::string const &name)
 Set server name. More...
 
ServerwelcomeMessage (std::string const &message)
 Set server welcome message. More...
 
DirectoryNoderoot () const
 Get root node. More...
 
Serverroot (DirectoryNode &root)
 Set root node. More...
 
Mode mode () const
 Get mode. More...
 
Servermode (Mode mode)
 Set mode. More...
 
void stop ()
 Stop the server. More...
 
- Public Member Functions inherited from senf::intrusive_refcount_base
virtual ~intrusive_refcount_base ()
 
refcount_t refcount () const
 
bool is_shared () const
 

Static Public Member Functions

static Serverstart (senf::INet4SocketAddress const &address)
 Start server on given IPv4 address/port. More...
 
static Serverstart (senf::INet6SocketAddress const &address)
 Start server on given IPv6 address/port. More...
 

Additional Inherited Members

- 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

Interactive console server.

This class provides an interactive console TCP server.

Idea:
To support blocking commands, we could give the Client 'suspend()' and 'resume()' members. suspend() would probably throw some kind of exception to transfer control back to the Client instance. on resume(), the command would be called again, maybe setting some flag or something. Example for use: Host name resolution: Here we can just built our own little host-name cache. When the name is not found, we ask the resolver to resolve it and call 'resume' when the name is found. Since it is in the cache now, the command will now complete.

Definition at line 53 of file Server.hh.

Member Typedef Documentation

◆ ServerHandle

typedef detail::ServerHandle senf::console::Server::ServerHandle

Definition at line 62 of file Server.hh.

Member Enumeration Documentation

◆ Mode

Enumerator
Automatic 
Interactive 
Noninteractive 

Definition at line 64 of file Server.hh.

Member Function Documentation

◆ mode() [1/2]

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

Get mode.

See also
mode(Mode)

◆ mode() [2/2]

Server& senf::console::Server::mode ( Mode  mode)

Set mode.

There are two Server types:

  • An interactive server displays a command prompt and optionally supports command-line editing.
  • A non-interactive server does not display any prompt and does not allow any interactive editing. This type of server is used for (remote) scripting.

The mode parameter selects between these modes. In Automatic (the default), a client connection is considered to be interactive if there is no data traffic in the first 500ms after the connection is opened.

◆ name() [1/2]

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

Get server name.

This information is used in the prompt string.

◆ name() [2/2]

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

Set server name.

This information is used in the prompt string.

◆ root() [1/2]

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

Get root node.

◆ root() [2/2]

Server& senf::console::Server::root ( DirectoryNode root)

Set root node.

node will be the root node for all clients launched from this server.

◆ start() [1/2]

senf::console::Server & Server::start ( senf::INet4SocketAddress const &  address)
static

Start server on given IPv4 address/port.

Definition at line 85 of file Server.cc.

◆ start() [2/2]

senf::console::Server & Server::start ( senf::INet6SocketAddress const &  address)
static

Start server on given IPv6 address/port.

Definition at line 95 of file Server.cc.

◆ stop()

void senf::console::Server::stop ( )

Stop the server.

All clients will be closed

Warning
The Server instance itself will be deleted

◆ welcomeMessage()

senf::console::Server & Server::welcomeMessage ( std::string const &  message)

Set server welcome message.

This message is printed on login.

Definition at line 153 of file Server.cc.


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