-
Notifications
You must be signed in to change notification settings - Fork 4
/
WebSocketOptions.cs
78 lines (68 loc) · 3.02 KB
/
WebSocketOptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using System.Collections.Generic;
namespace net.vieapps.Components.WebSockets
{
/// <summary>
/// Options for initializing a WebSocket connection
/// </summary>
public class WebSocketOptions
{
/// <summary>
/// Gets or sets how often to send ping requests to the remote endpoint
/// </summary>
/// <remarks>
/// This is done to prevent proxy servers from closing your connection, the default is TimeSpan.Zero meaning that it is disabled.
/// WebSocket servers usually send ping messages so it is not normally necessary for the client to send them (hence the TimeSpan.Zero default)
/// You can manually control ping pong messages using the PingPongManager class. If you do that it is advisible to set this KeepAliveInterval to zero.
/// </remarks>
public TimeSpan KeepAliveInterval { get; set; } = TimeSpan.Zero;
/// <summary>
/// Gets or Sets the sub-protocol (Sec-WebSocket-Protocol)
/// </summary>
public string SubProtocol { get; set; }
/// <summary>
/// Gets or Sets the extensions (Sec-WebSocket-Extensions)
/// </summary>
public string Extensions { get; set; }
/// <summary>
/// Gets or Sets state to send a message immediately or not
/// </summary>
/// <remarks>
/// Set to true to send a message immediately with the least amount of latency (typical usage for chat)
/// This will disable Nagle's algorithm which can cause high tcp latency for small packets sent infrequently
/// However, if you are streaming large packets or sending large numbers of small packets frequently it is advisable to set NoDelay to false
/// This way data will be bundled into larger packets for better throughput
/// </remarks>
public bool NoDelay { get; set; } = true;
/// <summary>
/// Gets or Sets the additional headers
/// </summary>
public Dictionary<string, string> AdditionalHeaders { get; set; } = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
/// <summary>
/// Gets or Sets the state to include the full exception (with stack trace) in the close response when an exception is encountered and the WebSocket connection is closed
/// </summary>
/// <remarks>
/// The default is false
/// </remarks>
public bool IncludeExceptionInCloseResponse { get; set; } = false;
/// <summary>
/// Gets or Sets whether remote certificate errors should be ignored
/// </summary>
/// <remarks>
/// The default is false
/// </remarks>
public bool IgnoreCertificateErrors { get; set; } = false;
/// <summary>
/// Gets or Sets the function to prepare the custom 'PING' playload to send a 'PING' message
/// </summary>
public Func<ManagedWebSocket, byte[]> GetPingPayload { get; set; }
/// <summary>
/// Gets or Sets the function to prepare the custom 'PONG' playload to response to a 'PING' message
/// </summary>
public Func<ManagedWebSocket, byte[], byte[]> GetPongPayload { get; set; }
/// <summary>
/// Gets or Sets the action to fire when a 'PONG' message has been sent
/// </summary>
public Action<ManagedWebSocket, byte[]> OnPong { get; set; }
}
}