websocket-sharp : WebSocketSharp Namespace

WebSocket Class

Implements the WebSocket interface.

Syntax

public class WebSocket : IDisposable

Remarks

The WebSocket class provides methods and properties for two-way communication using the WebSocket protocol (RFC 6455).

Requirements

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

Members

See Also: Inherited members from object.

Public Constructors

WebSocket (string, params string[])
Initializes a new instance of the WebSocketSharp.WebSocket class with the specified WebSocket URL and subprotocols.
Initializes a new instance of the WebSocketSharp.WebSocket class with the specified WebSocket URL, OnOpen, OnMessage, OnError, OnClose event handlers and subprotocols.

Public Properties

[read-only]
Extensions string . Gets the extensions selected by the server.
[read-only]
IsAlive bool . Gets a value indicating whether a connection is alive.
[read-only]
IsSecure bool . Gets a value indicating whether a connection is secure.
[read-only]
Protocol string . Gets the subprotocol selected by the server.
[read-only]
ReadyState WsState . Gets the state of the connection.
[read-only]
UnsentBuffer byte[]. Gets the buffer that contains unsent WebSocket frames.
[read-only]
UnsentCount uint . Gets the count of unsent WebSocket frames.
Url Uri . Gets or sets the WebSocket URL.

Public Methods

Close ()
Closes the connection and releases all associated resources after sends a Close control frame.
Close (ushort)
Closes the connection and releases all associated resources after sends a Close control frame.
Close (WebSocketSharp.Frame.CloseStatusCode)
Closes the connection and releases all associated resources after sends a Close control frame.
Close (ushort, string)
Closes the connection and releases all associated resources after sends a Close control frame.
Close (WebSocketSharp.Frame.CloseStatusCode, string)
Closes the connection and releases all associated resources after sends a Close control frame.
Connect ()
Establishes a connection.
Dispose ()
Closes the connection and releases all associated resources after sends a Close control frame.
Ping () : bool
Sends a Ping frame using the connection.
Ping (string) : bool
Sends a Ping frame with a message using the connection.
Send (byte[])
Sends a binary data using the connection.
Send (System.IO.FileInfo)
Sends a binary data using the connection.
Send (string)
Sends a text data using the connection.
SendAsync (byte[], Action)
Sends a binary data asynchronously using the connection.
SendAsync (System.IO.FileInfo, Action)
Sends a binary data asynchronously using the connection.
SendAsync (string, Action)
Sends a text data asynchronously using the connection.

Public Events

OnClose Occurs when the WebSocket receives a Close frame or the Close method is called.
OnError Occurs when the WebSocket gets an error.
OnMessage Occurs when the WebSocket receives a data frame.
OnOpen Occurs when the WebSocket connection has been established.

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

WebSocket Constructor

Initializes a new instance of the WebSocketSharp.WebSocket class with the specified WebSocket URL and subprotocols.

Syntax

public WebSocket (string url, params string[] protocols)

Parameters

url
A string that contains the WebSocket URL.
protocols
An array of string that contains the WebSocket subprotocols if any.

Exceptions

Type Reason
ArgumentNullException url is null.
ArgumentException url is not valid WebSocket URL.

Remarks

Documentation for this section has not yet been entered.

Requirements

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

WebSocket Constructor

Initializes a new instance of the WebSocketSharp.WebSocket class with the specified WebSocket URL, OnOpen, OnMessage, OnError, OnClose event handlers and subprotocols.

Syntax

public WebSocket (string url, EventHandler onOpen, EventHandler<MessageEventArgs> onMessage, EventHandler<ErrorEventArgs> onError, EventHandler<CloseEventArgs> onClose, params string[] protocols)

Parameters

url
A string that contains the WebSocket URL.
onOpen
An OnOpen event handler.
onMessage
An OnMessage event handler.
onError
An OnError event handler.
onClose
An OnClose event handler.
protocols
An array of string that contains the WebSocket subprotocols if any.

Exceptions

Type Reason
ArgumentNullException url is null.
ArgumentException url is not valid WebSocket URL.

Remarks

Documentation for this section has not yet been entered.

Requirements

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

Close Method

Closes the connection and releases all associated resources after sends a Close control frame.

Syntax

public void Close ()

Remarks

Documentation for this section has not yet been entered.

Requirements

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

Close Method

Closes the connection and releases all associated resources after sends a Close control frame.

Syntax

public void Close (ushort code)

Parameters

code
A ushort that contains a status code indicating a reason for closure.

Remarks

Documentation for this section has not yet been entered.

Requirements

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

Close Method

Closes the connection and releases all associated resources after sends a Close control frame.

Syntax

Parameters

code
A WebSocketSharp.Frame.CloseStatusCode that contains a status code indicating a reason for closure.

Remarks

Documentation for this section has not yet been entered.

Requirements

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

Close Method

Closes the connection and releases all associated resources after sends a Close control frame.

Syntax

public void Close (ushort code, string reason)

Parameters

code
A ushort that contains a status code indicating a reason for closure.
reason
A string that contains a reason for closure.

Remarks

Documentation for this section has not yet been entered.

Requirements

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

Close Method

Closes the connection and releases all associated resources after sends a Close control frame.

Syntax

Parameters

code
A WebSocketSharp.Frame.CloseStatusCode that contains a status code indicating a reason for closure.
reason
A string that contains a reason for closure.

Remarks

Documentation for this section has not yet been entered.

Requirements

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

Connect Method

Establishes a connection.

Syntax

public void Connect ()

Remarks

Documentation for this section has not yet been entered.

Requirements

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

Dispose Method

Closes the connection and releases all associated resources after sends a Close control frame.

Syntax

public void Dispose ()

Remarks

Call WebSocket.Dispose when you are finished using the WebSocketSharp.WebSocket. The WebSocket.Dispose method leaves the WebSocketSharp.WebSocket in an unusable state. After calling WebSocket.Dispose, you must release all references to the WebSocketSharp.WebSocket so the garbage collector can reclaim the memory that the WebSocketSharp.WebSocket was occupying.

Requirements

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

Extensions Property

Gets the extensions selected by the server.

Syntax

public string Extensions { get; }

Value

A string that contains the extensions if any. By default, String.Empty. (Currently this will only ever be the String.Empty.)

Remarks

Documentation for this section has not yet been entered.

Requirements

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

IsAlive Property

Gets a value indicating whether a connection is alive.

Syntax

public bool IsAlive { get; }

Value

true if the connection is alive; otherwise, false.

Remarks

Documentation for this section has not yet been entered.

Requirements

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

IsSecure Property

Gets a value indicating whether a connection is secure.

Syntax

public bool IsSecure { get; }

Value

true if the connection is secure; otherwise, false.

Remarks

Documentation for this section has not yet been entered.

Requirements

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

OnClose Event

Occurs when the WebSocket receives a Close frame or the Close method is called.

Syntax

public event EventHandler<CloseEventArgs> OnClose

Remarks

Documentation for this section has not yet been entered.

Requirements

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

OnError Event

Occurs when the WebSocket gets an error.

Syntax

public event EventHandler<ErrorEventArgs> OnError

Remarks

Documentation for this section has not yet been entered.

Requirements

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

OnMessage Event

Occurs when the WebSocket receives a data frame.

Syntax

public event EventHandler<MessageEventArgs> OnMessage

Remarks

Documentation for this section has not yet been entered.

Requirements

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

OnOpen Event

Occurs when the WebSocket connection has been established.

Syntax

public event EventHandler OnOpen

Remarks

Documentation for this section has not yet been entered.

Requirements

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

Ping Method

Sends a Ping frame using the connection.

Syntax

public bool Ping ()

Returns

true if the WebSocket receives a Pong frame in a time; otherwise, false.

Remarks

Documentation for this section has not yet been entered.

Requirements

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

Ping Method

Sends a Ping frame with a message using the connection.

Syntax

public bool Ping (string message)

Parameters

message
A string that contains the message to be sent.

Returns

true if the WebSocket receives a Pong frame in a time; otherwise, false.

Remarks

Documentation for this section has not yet been entered.

Requirements

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

Protocol Property

Gets the subprotocol selected by the server.

Syntax

public string Protocol { get; }

Value

A string that contains the subprotocol if any. By default, String.Empty.

Remarks

Documentation for this section has not yet been entered.

Requirements

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

ReadyState Property

Gets the state of the connection.

Syntax

public WsState ReadyState { get; }

Value

One of the WebSocketSharp.WsState. By default, WsState.CONNECTING.

Remarks

Documentation for this section has not yet been entered.

Requirements

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

Send Method

Sends a binary data using the connection.

Syntax

public void Send (byte[] data)

Parameters

data
An array of byte that contains the binary data to be sent.

Remarks

Documentation for this section has not yet been entered.

Requirements

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

Send Method

Sends a binary data using the connection.

Syntax

public void Send (System.IO.FileInfo file)

Parameters

file
A System.IO.FileInfo that contains the binary data to be sent.

Remarks

Documentation for this section has not yet been entered.

Requirements

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

Send Method

Sends a text data using the connection.

Syntax

public void Send (string data)

Parameters

data
A string that contains the text data to be sent.

Remarks

Documentation for this section has not yet been entered.

Requirements

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

SendAsync Method

Sends a binary data asynchronously using the connection.

Syntax

public void SendAsync (byte[] data, Action completed)

Parameters

data
An array of byte that contains the binary data to be sent.
completed
An Action delegate that contains the method(s) that is called when an asynchronous operation completes.

Remarks

Documentation for this section has not yet been entered.

Requirements

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

SendAsync Method

Sends a binary data asynchronously using the connection.

Syntax

public void SendAsync (System.IO.FileInfo file, Action completed)

Parameters

file
A System.IO.FileInfo that contains the binary data to be sent.
completed
An Action delegate that contains the method(s) that is called when an asynchronous operation completes.

Remarks

Documentation for this section has not yet been entered.

Requirements

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

SendAsync Method

Sends a text data asynchronously using the connection.

Syntax

public void SendAsync (string data, Action completed)

Parameters

data
A string that contains the text data to be sent.
completed
An Action delegate that contains the method(s) that is called when an asynchronous operation completes.

Remarks

Documentation for this section has not yet been entered.

Requirements

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

UnsentBuffer Property

Gets the buffer that contains unsent WebSocket frames.

Syntax

public byte[] UnsentBuffer { get; }

Value

An array of byte that contains unsent WebSocket frames.

Remarks

Documentation for this section has not yet been entered.

Requirements

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

UnsentCount Property

Gets the count of unsent WebSocket frames.

Syntax

public uint UnsentCount { get; }

Value

A uint that contains the count of unsent WebSocket frames.

Remarks

Documentation for this section has not yet been entered.

Requirements

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

Url Property

Gets or sets the WebSocket URL.

Syntax

public Uri Url { get; set; }

Value

A Uri that contains the WebSocket URL.

Remarks

Documentation for this section has not yet been entered.

Requirements

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