websocket-sharp : WebSocketSharp.Server Namespace

# WebSocketService Class

Provides the basic functions of the WebSocket service.

## Syntax

public abstract class WebSocketService

## Remarks

The WebSocketService class is an abstract class.

## Requirements

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

## Members

See Also: Inherited members from object.

## Public Constructors

| WebSocketService () | Initializes a new instance of the WebSocketSharp.Server.WebSocketService class.

## Public Properties

[read-only] | ID | string . Gets the ID of the WebSocketSharp.Server.WebSocketService instance.
[read-only] | IsBound | bool . Gets a value indicating whether the WebSocketSharp.Server.WebSocketService instance is bound to a WebSocketSharp.WebSocket.

## Protected Properties

[read-only] | QueryString | System.Collections.Specialized.NameValueCollection . Gets the collection of query string variables used in the WebSocket opening handshake.
[read-only] | Sessions | WebSocketServiceManager . Gets the sessions to the WebSocketSharp.Server.WebSocketService.

## Public Methods

Broadcast (byte[])

> Broadcasts the specified array of byte to the clients of every WebSocketSharp.Server.WebSocketService instances in the WebSocketService.Sessions.

Broadcast (string)

> Broadcasts the specified string to the clients of every WebSocketSharp.Server.WebSocketService instances in the WebSocketService.Sessions.

Broadping () : Dictionary<string, bool>

> Pings to the clients of every WebSocketSharp.Server.WebSocketService instances in the WebSocketService.Sessions.

Broadping (string) : Dictionary<string, bool>

> Pings with the specified string to the clients of every WebSocketSharp.Server.WebSocketService instances in the WebSocketService.Sessions.

Ping () : bool

> Pings to the client of the WebSocketSharp.Server.WebSocketService instance.

Ping (string) : bool

> Pings with the specified string to the client of the WebSocketSharp.Server.WebSocketService instance.

PingTo (string) : bool

> Pings to the client of the WebSocketSharp.Server.WebSocketService instance associated with the specified id.

PingTo (string, string) : bool

> Pings with the specified string to the client of the WebSocketSharp.Server.WebSocketService instance associated with the specified id.

Send (byte[])

> Sends a binary data to the client of the WebSocketSharp.Server.WebSocketService instance.

Send (string)

> Sends a text data to the client of the WebSocketSharp.Server.WebSocketService instance.

SendTo (string, byte[])

> Sends a binary data to the client of the WebSocketSharp.Server.WebSocketService instance associated with the specified id.

SendTo (string, string)

> Sends a text data to the client of the WebSocketSharp.Server.WebSocketService instance associated with the specified id.

Start ()

> Starts the WebSocketSharp.Server.WebSocketService instance.

Stop ()

> Stops the WebSocketSharp.Server.WebSocketService instance.

Stop (ushort, string)

> Stops the WebSocketSharp.Server.WebSocketService instance with the specified ushort and string.

Stop (WebSocketSharp.CloseStatusCode, string)

> Stops the WebSocketSharp.Server.WebSocketService instance with the specified WebSocketSharp.CloseStatusCode and string.

## Protected Methods

OnClose (WebSocketSharp.CloseEventArgs)

> Occurs when the inner WebSocketSharp.WebSocket receives a Close frame or the Stop method is called.

OnError (WebSocketSharp.ErrorEventArgs)

> Occurs when the inner WebSocketSharp.WebSocket gets an error.

OnMessage (WebSocketSharp.MessageEventArgs)

> Occurs when the inner WebSocketSharp.WebSocket receives a data frame.

OnOpen ()

> Occurs when the WebSocket connection has been established.

ProcessCookies (WebSocketSharp.Net.CookieCollection, WebSocketSharp.Net.CookieCollection) : bool

> Processes the cookies used in the WebSocket opening handshake.

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

### WebSocketService Constructor

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

> ## Syntax

> public WebSocketService ()

> ## 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 array of byte to the clients of every WebSocketSharp.Server.WebSocketService instances in the WebSocketService.Sessions.

> ## Syntax

> public void Broadcast (byte[] data)

> #### Parameters

> > data
> >   An array of byte to broadcast.

> ## 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 the clients of every WebSocketSharp.Server.WebSocketService instances in the WebSocketService.Sessions.

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

### Broadping Method

> Pings to the clients of every WebSocketSharp.Server.WebSocketService instances in the WebSocketService.Sessions.

> ## Syntax

> public Dictionary<string, bool> Broadping ()

> #### Returns

> > A Dictionary<string, bool> that contains the collection of IDs and values indicating whether each WebSocketSharp.Server.WebSocketService instances received a Pong in a time.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### Broadping Method

> Pings with the specified string to the clients of every WebSocketSharp.Server.WebSocketService instances in the WebSocketService.Sessions.

> ## Syntax

> public Dictionary<string, bool> Broadping (string message)

> #### Parameters

> > message
> >   A string that contains a message.

> #### Returns

> > A Dictionary<string, bool> that contains the collection of IDs and values indicating whether each WebSocketSharp.Server.WebSocketService instances received a Pong in a time.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### ID Property

> Gets the ID of the WebSocketSharp.Server.WebSocketService instance.

> ## Syntax

> public string ID { get; }

> #### Value

> > A string that contains an ID.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### IsBound Property

> Gets a value indicating whether the WebSocketSharp.Server.WebSocketService instance is bound to a WebSocketSharp.WebSocket.

> ## Syntax

> public bool IsBound { get; }

> #### Value

> > `true` if the WebSocketSharp.Server.WebSocketService instance is bound to a WebSocketSharp.WebSocket; otherwise, `false`.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### OnClose Method

> Occurs when the inner WebSocketSharp.WebSocket receives a Close frame or the Stop method is called.

> ## Syntax

> protected virtual void OnClose (WebSocketSharp.CloseEventArgs e)

> #### Parameters

> > e
> >   A WebSocketSharp.CloseEventArgs that contains the event data associated with a WebSocketSharp.WebSocket.OnClose event.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### OnError Method

> Occurs when the inner WebSocketSharp.WebSocket gets an error.

> ## Syntax

> protected virtual void OnError (WebSocketSharp.ErrorEventArgs e)

> #### Parameters

> > e
> >   An WebSocketSharp.ErrorEventArgs that contains the event data associated with a WebSocketSharp.WebSocket.OnError event.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### OnMessage Method

> Occurs when the inner WebSocketSharp.WebSocket receives a data frame.

> ## Syntax

> protected virtual void OnMessage (WebSocketSharp.MessageEventArgs e)

> #### Parameters

> > e
> >   A WebSocketSharp.MessageEventArgs that contains the event data associated with a WebSocketSharp.WebSocket.OnMessage event.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### OnOpen Method

> Occurs when the WebSocket connection has been established.

> ## Syntax

> protected virtual void OnOpen ()

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### Ping Method

> Pings to the client of the WebSocketSharp.Server.WebSocketService instance.

> ## Syntax

> public bool Ping ()

> #### Returns

> > `true` if the WebSocketSharp.Server.WebSocketService instance receives a Pong in a time; otherwise, `false`.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### Ping Method

> Pings with the specified string to the client of the WebSocketSharp.Server.WebSocketService instance.

> ## Syntax

> public bool Ping (string message)

> #### Parameters

> > message
> >   A string that contains a message.

> #### Returns

> > `true` if the WebSocketSharp.Server.WebSocketService instance receives a Pong in a time; otherwise, `false`.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### PingTo Method

> Pings to the client of the WebSocketSharp.Server.WebSocketService instance associated with the specified id.

> ## Syntax

> public bool PingTo (string id)

> #### Parameters

> > id
> >   A string that contains an ID that represents the destination for the Ping.

> #### Returns

> > `true` if the WebSocketSharp.Server.WebSocketService instance receives a Pong in a time; otherwise, `false`.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### PingTo Method

> Pings with the specified string to the client of the WebSocketSharp.Server.WebSocketService instance associated with the specified id.

> ## Syntax

> public bool PingTo (string id, string message)

> #### Parameters

> > id
> >   A string that contains an ID that represents the destination for the Ping.
> > message
> >   A string that contains a message.

> #### Returns

> > `true` if the WebSocketSharp.Server.WebSocketService instance receives a Pong in a time; otherwise, `false`.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### ProcessCookies Method

> Processes the cookies used in the WebSocket opening handshake.

> ## Syntax

> protected virtual bool ProcessCookies (WebSocketSharp.Net.CookieCollection request, WebSocketSharp.Net.CookieCollection response)

> #### Parameters

> > request
> >   A WebSocketSharp.Net.CookieCollection that contains a collection of the HTTP Cookies received from the client.
> > response
> >   A WebSocketSharp.Net.CookieCollection that contains a collection of the HTTP Cookies to send to the client.

> #### Returns

> > `true` if processing the cookies is successfully; otherwise, `false`.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### QueryString Property

> Gets the collection of query string variables used in the WebSocket opening handshake.

> ## Syntax

> protected System.Collections.Specialized.NameValueCollection QueryString { get; }

> #### Value

> > A System.Collections.Specialized.NameValueCollection that contains the collection of query string variables.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### Send Method

> Sends a binary data to the client of the WebSocketSharp.Server.WebSocketService instance.

> ## Syntax

> public void Send (byte[] data)

> #### Parameters

> > data
> >   An array of byte that contains a binary data to send.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### Send Method

> Sends a text data to the client of the WebSocketSharp.Server.WebSocketService instance.

> ## Syntax

> public void Send (string data)

> #### Parameters

> > data
> >   A string that contains a text data to send.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### SendTo Method

> Sends a binary data to the client of the WebSocketSharp.Server.WebSocketService instance associated with the specified id.

> ## Syntax

> public void SendTo (string id, byte[] data)

> #### Parameters

> > id
> >   A string that contains an ID that represents the destination for the data.
> > data
> >   An array of byte that contains a binary data to send.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### SendTo Method

> Sends a text data to the client of the WebSocketSharp.Server.WebSocketService instance associated with the specified id.

> ## Syntax

> public void SendTo (string id, string data)

> #### Parameters

> > id
> >   A string that contains an ID that represents the destination for the data.
> > data
> >   A string that contains a text data to send.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### Sessions Property

> Gets the sessions to the WebSocketSharp.Server.WebSocketService.

> ## Syntax

> protected WebSocketServiceManager Sessions { get; }

> #### Value

> > A WebSocketSharp.Server.WebSocketServiceManager that contains the sessions to the the WebSocketSharp.Server.WebSocketService.

> ## 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.WebSocketService instance.

> ## 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 the WebSocketSharp.Server.WebSocketService instance.

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

### Stop Method

> Stops the WebSocketSharp.Server.WebSocketService instance with the specified ushort and string.

> ## Syntax

> public void Stop (ushort code, string reason)

> #### Parameters

> > code
> >   A ushort that contains a status code indicating the reason for stop.
> > reason
> >   A string that contains a reason for stop.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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

### Stop Method

> Stops the WebSocketSharp.Server.WebSocketService instance with the specified WebSocketSharp.CloseStatusCode and string.

> ## Syntax

> public void Stop (WebSocketSharp.CloseStatusCode code, string reason)

> #### Parameters

> > code
> >   One of the WebSocketSharp.CloseStatusCode values that contains a status code indicating the reason for stop.
> > reason
> >   A string that contains a reason for stop.

> ## Remarks

> Documentation for this section has not yet been entered.

> ## Requirements

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