Daraja HTTP Framework 3.2.1-SNAPSHOT
HTTP server framework for Object Pascal
Loading...
Searching...
No Matches
TdjServer Class Reference

Basic server class for the Web Component framework. More...

Inheritance diagram for TdjServer:
TdjServerBase TdjHandlerWrapper IHandlerContainer TdjAbstractHandlerContainer

Public Member Functions

 TdjServer ()
 Create a TdjServer using the default host and port.
 TdjServer (const Integer APort)
 Create a TdjServer, using the specified port and the default host.
 TdjServer (const string AHost, const Integer APort=DEFAULT_BINDING_PORT)
 Create a TdjServer, using the specfied host and port.
 ~TdjServer ()
 Destructor.
 Add (TdjWebComponentContextHandler Context)
 Add a new context.
 AddConnector (const IConnector Connector)
 Add a preconfigured connector.
 AddConnector (const string Host, Integer Port=DEFAULT_BINDING_PORT)
 Create and add a connector for a host and port.
 AddHandler (const IHandler Handler)
 Add a handler to the container.
Integer ConnectorCount ()
 The number of connectors.
IConnector GetConnector (Integer Index)
 The connector at the given position, in the order the connectors were added.
 RemoveConnector (const IConnector Connector)
 Remove a previously added connector.
 RemoveHandler (const IHandler Handler)

Public Attributes

IHandler Handler

Protected Member Functions

TIdHTTPSession GetSession (TdjServerContext Context, TdjRequest Request, TdjResponse Response, const Boolean Create)
 Get a HTTP session.
 Handle (const string Target, TdjServerContext Context, TdjRequest Request, TdjResponse Response)

Detailed Description

Basic server class for the Web Component framework.

Constructor & Destructor Documentation

◆ TdjServer() [1/3]

TdjServer::TdjServer ( )

Create a TdjServer using the default host and port.

Referenced by Add(), ConnectorCount(), and GetConnector().

◆ TdjServer() [2/3]

TdjServer::TdjServer ( const Integer APort)

Create a TdjServer, using the specified port and the default host.

Parameters
APortthe port to be used.

◆ TdjServer() [3/3]

TdjServer::TdjServer ( const string AHost,
const Integer APort = DEFAULT_BINDING_PORT )

Create a TdjServer, using the specfied host and port.

Parameters
AHostthe host to be used.
APortthe port to be used.

◆ ~TdjServer()

TdjServer::~TdjServer ( )

Destructor.

References ConnectorCount().

Member Function Documentation

◆ Add()

TdjServer::Add ( TdjWebComponentContextHandler Context)

Add a new context.

Ownership: the server takes ownership of the context. It is destroyed together with the server; do not free it yourself. If a context with the same path is already registered, the passed context is freed and an EWebComponentException is raised.

Parameters
Contextthe context handler.
Exceptions
EWebComponentExceptionif the context path is already registered.

References TdjServer().

Referenced by ConnectorCount().

◆ AddConnector() [1/2]

TdjServer::AddConnector ( const IConnector Connector)

Add a preconfigured connector.

Ownership: the connector is held by an interface reference and is released when the server is destroyed. Do not free it yourself.

Parameters
Connectorthe connector
Exceptions
EWebComponentExceptionif a connector for the same host and port is already registered.

Referenced by ConnectorCount().

◆ AddConnector() [2/2]

TdjServer::AddConnector ( const string Host,
Integer Port = DEFAULT_BINDING_PORT )

Create and add a connector for a host and port.

Parameters
Hostthe connector host name
Portthe connector port number
Exceptions
EWebComponentExceptionif a connector for the same host and port is already registered.

◆ AddHandler()

TdjHandlerWrapper::AddHandler ( const IHandler Handler)
inherited

Add a handler to the container.

This implementation of AddHandler calls SetHandler with the passed handler. If this HandlerWrapper had a previous wrapped handler, then it is passed to a call to AddHandler on the passed handler.

Parameters
Handlerthe handler to be added

Referenced by TdjWebComponentContextHandler::AddWebFilter(), TdjServer::GetConnector(), and GetSession().

◆ ConnectorCount()

Integer TdjServer::ConnectorCount ( )

The number of connectors.

Returns
number of connectors

References TdjServer(), Add(), AddConnector(), DEFAULT_BINDING_PORT, TdjHandlerWrapper::Handler, ILifeCycle::IsStarted(), and ILifeCycle::Stop().

Referenced by ~TdjServer().

◆ GetConnector()

IConnector TdjServer::GetConnector ( Integer Index)

The connector at the given position, in the order the connectors were added.

Use together with ConnectorCount to enumerate the connectors.

Parameters
Indexzero-based position, 0 <= Index < ConnectorCount
Returns
the connector
Exceptions
EWebComponentExceptionif Index is out of range.

References TdjServer(), TdjHandlerWrapper::AddHandler(), and DEFAULT_BINDING_PORT.

◆ GetSession()

TIdHTTPSession TdjHandlerWrapper::GetSession ( TdjServerContext Context,
TdjRequest Request,
TdjResponse Response,
const Boolean Create )
protectedinherited

Get a HTTP session.

References AddHandler(), and Handler.

◆ Handle()

TdjServerBase::Handle ( const string Target,
TdjServerContext Context,
TdjRequest Request,
TdjResponse Response )
protectedinherited

Implements IHandler.

References TdjServerBase().

Referenced by DoStart().

◆ RemoveConnector()

TdjServer::RemoveConnector ( const IConnector Connector)

Remove a previously added connector.

If the server is started, the connector is stopped before it is removed.

Parameters
Connectorthe connector to remove
Exceptions
EWebComponentExceptionif the connector is not registered.

◆ RemoveHandler()

TdjHandlerWrapper::RemoveHandler ( const IHandler Handler)
inherited

Member Data Documentation

◆ Handler

IHandler TdjHandlerWrapper::Handler
inherited