websocket-sharp : WebSocketSharp.Server Namespace

# WebSocketServer Class

Provides the functions of the server that receives the WebSocket connection requests.

## Syntax

public class WebSocketServer : WebSocketServerBase

## Remarks

The WebSocketServer class provides the multi WebSocket service.

## Requirements

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

## Members

See Also: Inherited members from WebSocketServerBase.

## Public Constructors

| WebSocketServer () | Initializes a new instance of the WebSocketSharp.Server.WebSocketServer class.
| WebSocketServer (int) | Initializes a new instance of the WebSocketSharp.Server.WebSocketServer class that listens for incoming connection attempts on the specified port.
| WebSocketServer (string) | Initializes a new instance of the WebSocketSharp.Server.WebSocketServer class that listens for incoming connection attempts on the specified WebSocket URL.
| WebSocketServer (int, bool) | Initializes a new instance of the WebSocketSharp.Server.WebSocketServer class that listens for incoming connection attempts on the specified port and secure.
| WebSocketServer (System.Net.IPAddress, int) | Initializes a new instance of the WebSocketSharp.Server.WebSocketServer class that listens for incoming connection attempts on the specified address and port.
| WebSocketServer (System.Net.IPAddress, int, bool) | Initializes a new instance of the WebSocketSharp.Server.WebSocketServer class that listens for incoming connection attempts on the specified address, port and secure.

## Public Properties

[read-only] | Address | System.Net.IPAddress . Gets the local IP address on which to listen for incoming connection attempts. (Inherited from WebSocketServerBase.)
[read-only] | IsSecure | bool . Gets a value indicating whether the server provides secure connection. (Inherited from WebSocketServerBase.)
[read-only] | IsSelfHost | bool . Gets a value indicating whether the server is self host. (Inherited from WebSocketServerBase.)
[read-only] | Port | int . Gets the port on which to listen for incoming connection attempts. (Inherited from WebSocketServerBase.)
[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 clients periodically.

## Protected Properties

| BaseUri | Uri . Gets or sets the WebSocket URL on which to listen for incoming connection attempts. (Inherited from WebSocketServerBase.)

## Public Methods

AddWebSocketService<T> (string)

> Adds the specified type WebSocket service.

Broadcast (string)

> Broadcasts the specified string to all clients.

Start ()

> Starts to receive the WebSocket connection requests. (Inherited from WebSocketServerBase.)

override

Stop ()

> Stops receiving the WebSocket connection requests.

Stop ()

> Stops receiving the WebSocket connection requests. (Inherited from WebSocketServerBase.)

## Protected Methods

override

AcceptWebSocket (WebSocketSharp.Net.WebSockets.TcpListenerWebSocketContext)

> Accepts a WebSocket connection request.

abstract

AcceptWebSocket (WebSocketSharp.Net.WebSockets.TcpListenerWebSocketContext)

> Accepts a WebSocket connection request. (Inherited from WebSocketServerBase.)

Error (string)

> Occurs the WebSocketServerBase.OnError event with the specified string. (Inherited from WebSocketServerBase.)

## Public Events

| OnError | Occurs when the server gets an error. (Inherited from WebSocketServerBase.)

## 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

### WebSocketServer Constructor

> Initializes a new instance of the WebSocketSharp.Server.WebSocketServer class.

> ## Syntax

> public WebSocketServer ()

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### WebSocketServer Constructor

> Initializes a new instance of the WebSocketSharp.Server.WebSocketServer class that listens for incoming connection attempts on the specified port.

> ## Syntax

> public WebSocketServer (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)

### WebSocketServer Constructor

> Initializes a new instance of the WebSocketSharp.Server.WebSocketServer class that listens for incoming connection attempts on the specified WebSocket URL.

> ## Syntax

> public WebSocketServer (string url)

> #### Parameters

> > url
> >   A string that contains a WebSocket URL.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### WebSocketServer Constructor

> Initializes a new instance of the WebSocketSharp.Server.WebSocketServer class that listens for incoming connection attempts on the specified port and secure.

> ## Syntax

> public WebSocketServer (int port, bool secure)

> #### Parameters

> > port
> >   An int that contains a port number.
> > secure
> >   A bool that indicates providing a secure connection or not. (`true` indicates providing a secure connection.)

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### WebSocketServer Constructor

> Initializes a new instance of the WebSocketSharp.Server.WebSocketServer class that listens for incoming connection attempts on the specified address and port.

> ## Syntax

> public WebSocketServer (System.Net.IPAddress address, int port)

> #### Parameters

> > address
> >   A System.Net.IPAddress that contains a local IP address.
> > 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)

### WebSocketServer Constructor

> Initializes a new instance of the WebSocketSharp.Server.WebSocketServer class that listens for incoming connection attempts on the specified address, port and secure.

> ## Syntax

> public WebSocketServer (System.Net.IPAddress address, int port, bool secure)

> #### Parameters

> > address
> >   A System.Net.IPAddress that contains a local IP address.
> > port
> >   An int that contains a port number.
> > secure
> >   A bool that indicates providing a secure connection or not. (`true` indicates providing a secure connection.)

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### AcceptWebSocket Method

> Accepts a WebSocket connection request.

> ## Syntax

> protected override void AcceptWebSocket (WebSocketSharp.Net.WebSockets.TcpListenerWebSocketContext context)

> #### Parameters

> > context
> >   A WebSocketSharp.Net.WebSockets.TcpListenerWebSocketContext that contains the WebSocket connection request objects.

> ## 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)

### Broadcast Method

> Broadcasts the specified string to all clients.

> ## Syntax

> public void Broadcast (string data)

> #### Parameters

> > data
> >   A string to broadcast.

> ## 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)

### Stop Method

> Stops receiving the WebSocket connection requests.

> ## Syntax

> public override 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 clients periodically.

> ## Syntax

> public bool Sweeped { get; set; }

> #### Value

> > `true` if the server cleans up the inactive clients 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)