Class ClientWebSocket
- Namespace
- System.Net.WebSockets
- Assembly
- System.Net.WebSockets.dll
Provides a client for connecting to WebSocket services.
public class ClientWebSocket : WebSocket, IDisposable
- Inheritance
-
ClientWebSocket
- Implements
- Inherited Members
- Extension Methods
Constructors
ClientWebSocket(ClientWebSocketOptions)
Creates an instance of the WebSocketClient class.
public ClientWebSocket(ClientWebSocketOptions options = null)
Parameters
options
ClientWebSocketOptionsOptional ClientWebSocketOptions where extra options can be defined.
Properties
CACertificate
Gets or sets the root CA certificate used to authenticate with secure servers. This certificate is used only for wss connections; ws connections do not require this.
public X509Certificate CACertificate { get; set; }
Property Value
Host
The remote Host name to connect to.
public string Host { get; }
Property Value
IsSSL
If a secure connection is used.
public bool IsSSL { get; }
Property Value
Port
The remote Port to connect to.
public int Port { get; }
Property Value
Prefix
The remote Prefix to connect to.
public string Prefix { get; }
Property Value
SslProtocol
Gets or sets the TLS/SSL protocol used by the WebSocket class.
public SslProtocols SslProtocol { get; }
Property Value
- SslProtocols
One of the values defined in the SslProtocols enumeration.
SslVerification
Option for SSL verification. The default behavior is CertificateRequired.
public SslVerification SslVerification { get; set; }
Property Value
State
Gets the WebSocket state of the ClientWebSocket instance.
public override WebSocketState State { get; set; }
Property Value
- WebSocketState
The WebSocket state of the ClientWebSocket instance.
UseCustomCertificate
Option to use a custom certificate for authentication.
public bool UseCustomCertificate { get; }
Property Value
UseStoredDeviceCertificate
Option to use the certificate stored in the device as client or server certificate. The default option is false.
public bool UseStoredDeviceCertificate { get; set; }
Property Value
Methods
Connect(string, ClientWebSocketHeaders)
Connect to a WebSocket server.
public void Connect(string uri, ClientWebSocketHeaders headers = null)
Parameters
uri
stringThe URI of the WebSocket server to connect to.
headers
ClientWebSocketHeadersOptional ClientWebSocketHeaders for setting custom headers.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()