websocket-sharp : WebSocketSharp.Server Namespace

# HttpServer Class

Provides a simple HTTP server that allows to accept the WebSocket connection requests.

## Syntax

public class HttpServer

## Remarks

The HttpServer class provides the multi WebSocket service.

The HttpServer class needs the application configuration file to configure the server root path.

xml Example

                <?xml version="1.0" encoding="utf-8"?>
                <configuration>
                <appSettings>
                <add key="RootPath" value="./Public" />
                </appSettings>
                </configuration>

## Requirements

Namespace: WebSocketSharp.Server
Assembly: websocket-sharp (in websocket-sharp.dll)

## Members

See Also: Inherited members from object.

## Public Constructors

| HttpServer () | Initializes a new instance of the WebSocketSharp.Server.HttpServer class that listens for incoming requests on port 80.
| HttpServer (int) | Initializes a new instance of the WebSocketSharp.Server.HttpServer class that listens for incoming requests on the specified port.

## Public Properties

[read-only] | Port | int . Gets the port on which to listen for incoming requests.
[read-only] | ServicePaths | IEnumerable<string> . Gets the collection of paths associated with the every WebSocket services that the server provides.
| Sweeped | bool . Gets or sets a value indicating whether the server cleans up the inactive WebSocket service instances periodically.

## Public Methods

AddWebSocketService<T> (string)

> Adds the specified type WebSocket service.

GetFile (string) : byte[]

> Gets the contents of the specified file.

Start ()

> Starts the WebSocketSharp.Server.HttpServer.

Stop ()

> Shuts down the WebSocketSharp.Server.HttpServer.

## Public Events

| OnConnect | Occurs when the server receives an HTTP CONNECT request.
| OnDelete | Occurs when the server receives an HTTP DELETE request.
| OnError | Occurs when the server gets an error.
| OnGet | Occurs when the server receives an HTTP GET request.
| OnHead | Occurs when the server receives an HTTP HEAD request.
| OnOptions | Occurs when the server receives an HTTP OPTIONS request.
| OnPatch | Occurs when the server receives an HTTP PATCH request.
| OnPost | Occurs when the server receives an HTTP POST request.
| OnPut | Occurs when the server receives an HTTP PUT request.
| OnTrace | Occurs when the server receives an HTTP TRACE request.

## Extension Methods

static

IsNull<T> (this T) : bool

> Determines whether the specified object is `null`.

static

IsNullDo<T> (this T, Action) : bool

> Determines whether the specified object is `null`. And invokes the specified Action delegate if the specified object is `null`.

## Member Details

### HttpServer Constructor

> Initializes a new instance of the WebSocketSharp.Server.HttpServer class that listens for incoming requests on port 80.

> ## Syntax

> public HttpServer ()

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Server
> Assembly: websocket-sharp (in websocket-sharp.dll)

### HttpServer Constructor

> Initializes a new instance of the WebSocketSharp.Server.HttpServer class that listens for incoming requests on the specified port.

> ## Syntax

> public HttpServer (int port)

> #### Parameters

> > port
> >   An int that contains a port number.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Server
> Assembly: websocket-sharp (in websocket-sharp.dll)

### AddWebSocketService<T> Generic Method

> Adds the specified type WebSocket service.

> ## Syntax

> public void AddWebSocketService<T> (string absPath)
> where T : WebSocketSharp.Server.WebSocketService, new()

> #### Type Parameters

> > T
> >   The type of the WebSocket service. The T must inherit the WebSocketSharp.Server.WebSocketService class.

> #### Parameters

> > absPath
> >   A string that contains an absolute path associated with the WebSocket service.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Server
> Assembly: websocket-sharp (in websocket-sharp.dll)

### GetFile Method

> Gets the contents of the specified file.

> ## Syntax

> public byte[] GetFile (string path)

> #### Parameters

> > path
> >   A string that contains a virtual path to the file to get.

> #### Returns

> > An array of byte that contains the contents of the file.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Server
> Assembly: websocket-sharp (in websocket-sharp.dll)

### OnConnect Event

> Occurs when the server receives an HTTP CONNECT request.

> ## Syntax

> public event EventHandler<HttpRequestEventArgs> OnConnect

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Server
> Assembly: websocket-sharp (in websocket-sharp.dll)

### OnDelete Event

> Occurs when the server receives an HTTP DELETE request.

> ## Syntax

> public event EventHandler<HttpRequestEventArgs> OnDelete

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Server
> Assembly: websocket-sharp (in websocket-sharp.dll)

### OnError Event

> Occurs when the server gets an error.

> ## Syntax

> public event EventHandler<WebSocketSharp.ErrorEventArgs> OnError

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Server
> Assembly: websocket-sharp (in websocket-sharp.dll)

### OnGet Event

> Occurs when the server receives an HTTP GET request.

> ## Syntax

> public event EventHandler<HttpRequestEventArgs> OnGet

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Server
> Assembly: websocket-sharp (in websocket-sharp.dll)

### OnHead Event

> Occurs when the server receives an HTTP HEAD request.

> ## Syntax

> public event EventHandler<HttpRequestEventArgs> OnHead

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Server
> Assembly: websocket-sharp (in websocket-sharp.dll)

### OnOptions Event

> Occurs when the server receives an HTTP OPTIONS request.

> ## Syntax

> public event EventHandler<HttpRequestEventArgs> OnOptions

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Server
> Assembly: websocket-sharp (in websocket-sharp.dll)

### OnPatch Event

> Occurs when the server receives an HTTP PATCH request.

> ## Syntax

> public event EventHandler<HttpRequestEventArgs> OnPatch

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Server
> Assembly: websocket-sharp (in websocket-sharp.dll)

### OnPost Event

> Occurs when the server receives an HTTP POST request.

> ## Syntax

> public event EventHandler<HttpRequestEventArgs> OnPost

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Server
> Assembly: websocket-sharp (in websocket-sharp.dll)

### OnPut Event

> Occurs when the server receives an HTTP PUT request.

> ## Syntax

> public event EventHandler<HttpRequestEventArgs> OnPut

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Server
> Assembly: websocket-sharp (in websocket-sharp.dll)

### OnTrace Event

> Occurs when the server receives an HTTP TRACE request.

> ## Syntax

> public event EventHandler<HttpRequestEventArgs> OnTrace

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Server
> Assembly: websocket-sharp (in websocket-sharp.dll)

### Port Property

> Gets the port on which to listen for incoming requests.

> ## Syntax

> public int Port { get; }

> #### Value

> > An int that contains a port number.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Server
> Assembly: websocket-sharp (in websocket-sharp.dll)

### ServicePaths Property

> Gets the collection of paths associated with the every WebSocket services that the server provides.

> ## Syntax

> public IEnumerable<string> ServicePaths { get; }

> #### Value

> > An IEnumerable<string> that contains the collection of paths.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Server
> Assembly: websocket-sharp (in websocket-sharp.dll)

### Start Method

> Starts the WebSocketSharp.Server.HttpServer.

> ## Syntax

> public void Start ()

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Server
> Assembly: websocket-sharp (in websocket-sharp.dll)

### Stop Method

> Shuts down the WebSocketSharp.Server.HttpServer.

> ## Syntax

> public void Stop ()

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Server
> Assembly: websocket-sharp (in websocket-sharp.dll)

### Sweeped Property

> Gets or sets a value indicating whether the server cleans up the inactive WebSocket service instances periodically.

> ## Syntax

> public bool Sweeped { get; set; }

> #### Value

> > `true` if the server cleans up the inactive WebSocket service instances every 60 seconds; otherwise, `false`. The default value is `true`.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

> Namespace: WebSocketSharp.Server
> Assembly: websocket-sharp (in websocket-sharp.dll)