C# Class Terrarium.Net.HttpNamespaceManager

The HTTP Namespace manager provides the basic web server type features required for the Terrarium application to function when in peer to peer mode and enable easy transmission of peer messages.
Datei anzeigen Open project: terrariumapp/terrarium Class Usage Examples

Public Methods

Method Description
GetRequestCallback ( IAsyncResult asyncResult ) : void

This method receives requests from other peers and maps the URI namespace or resource name to an actual namespace handler. If one exists then the namespace handler is invoked to process the request. If not some default processing is used.

HandleBadRequest ( Terrarium.Net.HttpApplication state, string message ) : void

Used to handle a request where the method is supported but insufficient data is available. The primary culprit here is a POST operation with no POST data.

HandleUnsupportedMethod ( Terrarium.Net.HttpApplication state ) : void

Handles a method that is not supported by the current namespace implementation. This happens whenever a users requests a namespace using a method that isn't valid. This should only happen if Terrarium's of differing versions connect to one another, or someone hits the peer with a web browser and changes the Method to something other than GET or POST.

HandleUnsupportedNamespace ( Terrarium.Net.HttpApplication state ) : void

Handles a namespace that isn't currently bound by this namespace manager. This could happen because of case sensitivity issues, trailing path characters or any other string morph that causes the namespace to not match one that is currently registered. This should only happen through a failed user connection using a web browser and a mistyped path.

HttpNamespaceManager ( ) : System

Don't create a new HttpNamespaceManager this way, use the static methods instead.

ReadCallback ( IAsyncResult asyncResult ) : void

Callback used for asynchronously reading a request stream. Used in order to process transfers will still accepting new connections.

RegisterNamespace ( string ns, IHttpNamespaceHandler nsHandler ) : void

Registers a namespace handler for use with a specific namespace. A namespace is the same as a web URI that you might append to any web server to get at some resource.

Start ( string hostIP, int port ) : void

Start listening on the given host IP Address, on the given port.

Stop ( ) : void

Shuts down the namespace manager by shutting down the _listener. Cleans up any references to the _listener.

UnregisterNamespace ( string ns ) : void

Removes a registered namespace from the list so it can no longer be accessed.

Private Methods

Method Description
OnAfterProcessRequest ( ) : void
OnBeforeProcessRequest ( ) : void

Method Details

GetRequestCallback() public method

This method receives requests from other peers and maps the URI namespace or resource name to an actual namespace handler. If one exists then the namespace handler is invoked to process the request. If not some default processing is used.
public GetRequestCallback ( IAsyncResult asyncResult ) : void
asyncResult IAsyncResult The Async object for the request.
return void

HandleBadRequest() public method

Used to handle a request where the method is supported but insufficient data is available. The primary culprit here is a POST operation with no POST data.
public HandleBadRequest ( Terrarium.Net.HttpApplication state, string message ) : void
state Terrarium.Net.HttpApplication The web application state object for this request.
message string The message to be sent to the client to describe the failure.
return void

HandleUnsupportedMethod() public method

Handles a method that is not supported by the current namespace implementation. This happens whenever a users requests a namespace using a method that isn't valid. This should only happen if Terrarium's of differing versions connect to one another, or someone hits the peer with a web browser and changes the Method to something other than GET or POST.
public HandleUnsupportedMethod ( Terrarium.Net.HttpApplication state ) : void
state Terrarium.Net.HttpApplication The web server state object for the connection.
return void

HandleUnsupportedNamespace() public method

Handles a namespace that isn't currently bound by this namespace manager. This could happen because of case sensitivity issues, trailing path characters or any other string morph that causes the namespace to not match one that is currently registered. This should only happen through a failed user connection using a web browser and a mistyped path.
public HandleUnsupportedNamespace ( Terrarium.Net.HttpApplication state ) : void
state Terrarium.Net.HttpApplication The web application state for the current connection.
return void

HttpNamespaceManager() public method

Don't create a new HttpNamespaceManager this way, use the static methods instead.
public HttpNamespaceManager ( ) : System
return System

ReadCallback() public method

Callback used for asynchronously reading a request stream. Used in order to process transfers will still accepting new connections.
public ReadCallback ( IAsyncResult asyncResult ) : void
asyncResult IAsyncResult The Async object representing the results of the read.
return void

RegisterNamespace() public method

Registers a namespace handler for use with a specific namespace. A namespace is the same as a web URI that you might append to any web server to get at some resource.
public RegisterNamespace ( string ns, IHttpNamespaceHandler nsHandler ) : void
ns string The namespace or path of the resource to be handled.
nsHandler IHttpNamespaceHandler The IHttpNamespaceHandler implementation that will handle the request.
return void

Start() public method

Start listening on the given host IP Address, on the given port.
public Start ( string hostIP, int port ) : void
hostIP string The host's IP address to bind to.
port int The port to bind on.
return void

Stop() public method

Shuts down the namespace manager by shutting down the _listener. Cleans up any references to the _listener.
public Stop ( ) : void
return void

UnregisterNamespace() public method

Removes a registered namespace from the list so it can no longer be accessed.
public UnregisterNamespace ( string ns ) : void
ns string The namespace or path of the resource to be removed.
return void