Stephen Adkins > App-Context-0.968 > App::Context::NetServer

Download:
App-Context-0.968.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  3
Open  0
View/Report Bugs
Module Version: 6004   Source  

NAME ^

App::Context::NetServer - context in which we are currently running

SYNOPSIS ^

   # ... official way to get a Context object ...
   use App;
   $context = App->context();
   $config = $context->config();   # get the configuration
   $config->dispatch_events();     # dispatch events

   # ... alternative way (used internally) ...
   use App::Context::NetServer;
   $context = App::Context::NetServer->new();

DESCRIPTION ^

A Context class models the environment (aka "context) in which the current execution thread is running. For the App::Context::NetServer class, this is the runtime environment of a server with any of the following Net::Server personalities.

  * Net::Server                - generic, single-connection server
  * Net::Server::INET          - a server controlled by inetd
  * Net::Server::Fork          - a forking server
  * Net::Server::PreForkSimple - a prefork server with constant # children
  * Net::Server::PreFork       - a prefork server with varying # children

Protected Methods: ^

The following methods are intended to be called by subclasses of the current class.

_init()

The _init() method is called from within the standard Context constructor.

The _init() method sets debug flags.

    * Signature: $context->_init($args)
    * Param:     $args            hash{string} [in]
    * Return:    void
    * Throws:    App::Exception
    * Since:     0.01

    Sample Usage: 

    $context->_init($args);

Protected Methods ^

These methods are considered protected because no class is ever supposed to call them. They may however be called by the context-specific drivers.

dispatch_events()

The dispatch_events() method is called at server startup. This method is not expected to return control until the server is exiting.

    * Signature: $context->dispatch_events()
    * Param:     void
    * Return:    void
    * Throws:    App::Exception
    * Since:     0.01

    Sample Usage: 

    $context->dispatch_events();

send_response()

    * Signature: $context->send_response()
    * Param:     void
    * Return:    void
    * Throws:    App::Exception
    * Since:     0.01

    Sample Usage: 

    $context->send_response();

set_header()

    * Signature: $context->set_header()
    * Param:     void
    * Return:    void
    * Throws:    App::Exception
    * Since:     0.01

    Sample Usage: 

    $context->set_header();

request()

    * Signature: $context->request()
    * Param:     void
    * Return:    void
    * Throws:    App::Exception
    * Since:     0.01

    Sample Usage: 

    $context->request();

The request() method gets the current Request being handled in the Context.

response()

    * Signature: $context->response()
    * Param:     void
    * Return:    void
    * Throws:    App::Exception
    * Since:     0.01

    Sample Usage: 

    $context->response();

The response() method gets the current Request being handled in the Context.

Public Methods: ^

user()

The user() method returns the username of the authenticated user. The special name, "guest", refers to the unauthenticated (anonymous) user.

    * Signature: $username = $self->user();
    * Param:  void
    * Return: string
    * Throws: <none>
    * Since:  0.01

    Sample Usage: 

    $username = $context->user();

In a request/response environment, this turns out to be a convenience method which gets the authenticated user from the current Request object.

syntax highlighting: