websocket-sharp : WebSocketSharp.Server Namespace

HttpServer Class

Provides the functions of 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

Initializes a new instance of the WebSocketSharp.Server.HttpServer class that listens for incoming requests on port 80.
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 to receive incoming requests.
Stop ()
Stops receiving incoming requests.

Public Events

OnError Occurs when the server gets an error.
OnResponseToConnect Occurs when the server receives an HTTP CONNECT request.
OnResponseToDelete Occurs when the server receives an HTTP DELETE request.
OnResponseToGet Occurs when the server receives an HTTP GET request.
OnResponseToHead Occurs when the server receives an HTTP HEAD request.
OnResponseToOptions Occurs when the server receives an HTTP OPTIONS request.
OnResponseToPatch Occurs when the server receives an HTTP PATCH request.
OnResponseToPost Occurs when the server receives an HTTP POST request.
OnResponseToPut Occurs when the server receives an HTTP PUT request.
OnResponseToTrace 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)

OnError Event

Occurs when the server gets an error.

Syntax

Remarks

Documentation for this section has not yet been entered.

Requirements

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

OnResponseToConnect Event

Occurs when the server receives an HTTP CONNECT request.

Syntax

public event EventHandler<ResponseEventArgs> OnResponseToConnect

Remarks

Documentation for this section has not yet been entered.

Requirements

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

OnResponseToDelete Event

Occurs when the server receives an HTTP DELETE request.

Syntax

public event EventHandler<ResponseEventArgs> OnResponseToDelete

Remarks

Documentation for this section has not yet been entered.

Requirements

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

OnResponseToGet Event

Occurs when the server receives an HTTP GET request.

Syntax

public event EventHandler<ResponseEventArgs> OnResponseToGet

Remarks

Documentation for this section has not yet been entered.

Requirements

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

OnResponseToHead Event

Occurs when the server receives an HTTP HEAD request.

Syntax

public event EventHandler<ResponseEventArgs> OnResponseToHead

Remarks

Documentation for this section has not yet been entered.

Requirements

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

OnResponseToOptions Event

Occurs when the server receives an HTTP OPTIONS request.

Syntax

public event EventHandler<ResponseEventArgs> OnResponseToOptions

Remarks

Documentation for this section has not yet been entered.

Requirements

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

OnResponseToPatch Event

Occurs when the server receives an HTTP PATCH request.

Syntax

public event EventHandler<ResponseEventArgs> OnResponseToPatch

Remarks

Documentation for this section has not yet been entered.

Requirements

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

OnResponseToPost Event

Occurs when the server receives an HTTP POST request.

Syntax

public event EventHandler<ResponseEventArgs> OnResponseToPost

Remarks

Documentation for this section has not yet been entered.

Requirements

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

OnResponseToPut Event

Occurs when the server receives an HTTP PUT request.

Syntax

public event EventHandler<ResponseEventArgs> OnResponseToPut

Remarks

Documentation for this section has not yet been entered.

Requirements

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

OnResponseToTrace Event

Occurs when the server receives an HTTP TRACE request.

Syntax

public event EventHandler<ResponseEventArgs> OnResponseToTrace

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 to receive incoming requests.

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

Stops receiving incoming requests.

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)