Interface IWebSocketClient
Namespace: KSharpPlus.Net.WebSocket
Assembly: KSharpPlus.dll
Syntax
public interface IWebSocketClient
Properties
| Improve this Doc View SourceDefaultHeaders
Gets the collection of default headers to send when connecting to the remote endpoint.
Declaration
IReadOnlyDictionary<string, string> DefaultHeaders { get; }
Property Value
Type | Description |
---|---|
IReadOnlyDictionary<String, String> |
Proxy
Gets the proxy settings for this client.
Declaration
IWebProxy Proxy { get; }
Property Value
Type | Description |
---|---|
IWebProxy |
Methods
| Improve this Doc View SourceAddDefaultHeader(String, String)
Adds a header to the default header collection.
Declaration
bool AddDefaultHeader(string name, string value)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name of the header to add. |
String | value | Value of the header to add. |
Returns
Type | Description |
---|---|
Boolean | Whether the operation succeeded. |
ConnectAsync(Uri)
Connects to a specified remote WebSocket endpoint.
Declaration
Task ConnectAsync(Uri uri)
Parameters
Type | Name | Description |
---|---|---|
Uri | uri | The URI of the WebSocket endpoint. |
Returns
Type | Description |
---|---|
Task |
DisconnectAsync(Int32, String)
Disconnects the WebSocket connection.
Declaration
Task DisconnectAsync(int code = 1000, string message = "")
Parameters
Type | Name | Description |
---|---|---|
Int32 | code | |
String | message |
Returns
Type | Description |
---|---|
Task |
RemoveDefaultHeader(String)
Removes a header from the default header collection.
Declaration
bool RemoveDefaultHeader(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name of the header to remove. |
Returns
Type | Description |
---|---|
Boolean | Whether the operation succeeded. |
SendMessageAsync(String)
Send a message to the WebSocket server.
Declaration
Task SendMessageAsync(string message)
Parameters
Type | Name | Description |
---|---|---|
String | message | The message to send. |
Returns
Type | Description |
---|---|
Task |
Events
| Improve this Doc View SourceConnected
Triggered when the client connects successfully.
Declaration
event AsyncEventHandler<IWebSocketClient, SocketEventArgs> Connected
Event Type
Type | Description |
---|---|
AsyncEventHandler<IWebSocketClient, SocketEventArgs> |
Disconnected
Triggered when the client is disconnected.
Declaration
event AsyncEventHandler<IWebSocketClient, SocketCloseEventArgs> Disconnected
Event Type
Type | Description |
---|---|
AsyncEventHandler<IWebSocketClient, SocketCloseEventArgs> |
ExceptionThrown
Triggered when an error occurs in the client.
Declaration
event AsyncEventHandler<IWebSocketClient, SocketErrorEventArgs> ExceptionThrown
Event Type
Type | Description |
---|---|
AsyncEventHandler<IWebSocketClient, SocketErrorEventArgs> |
MessageReceived
Triggered when the client receives a message from the remote party.
Declaration
event AsyncEventHandler<IWebSocketClient, SocketMessageEventArgs> MessageReceived
Event Type
Type | Description |
---|---|
AsyncEventHandler<IWebSocketClient, SocketMessageEventArgs> |