-
Notifications
You must be signed in to change notification settings - Fork 12
/
ClientOptions.cs
73 lines (61 loc) · 2.33 KB
/
ClientOptions.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
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using Newtonsoft.Json;
using Supabase.Realtime.Socket;
namespace Supabase.Realtime;
/// <summary>
/// Options used when initializing a <see cref="Client"/>
/// </summary>
public class ClientOptions
{
/// <summary>
/// The function to encode outgoing messages. Defaults to JSON
/// </summary>
public Action<object, Action<string>>? Encode { get; set; }
/// <summary>
/// The function to decode incoming messages.
/// </summary>
public Action<string, Action<SocketResponse?>>? Decode { get; set; }
/// <summary>
/// The Websocket Transport, for example WebSocket.
/// </summary>
public string Transport { get; set; } = Constants.TransportWebsocket;
/// <summary>
/// The default timeout in milliseconds to trigger push timeouts.
/// </summary>
public TimeSpan Timeout { get; set; } = TimeSpan.FromMilliseconds(Constants.DefaultTimeout);
/// <summary>
/// @todo Presently unused: Limit the number of events that can be sent per second.
/// </summary>
public int EventsPerSecond { get; set; } = 10;
/// <summary>
/// The interval to send a heartbeat message
/// </summary>
public TimeSpan HeartbeatInterval { get; set; } = TimeSpan.FromSeconds(20);
/// <summary>
/// The interval to reconnect
/// </summary>
public Func<int, TimeSpan> ReconnectAfterInterval { get; set; } = (tries) =>
{
var intervals = new[] { 30, 45, 60, 120 };
return TimeSpan.FromSeconds(tries < intervals.Length ? intervals[tries] : intervals[intervals.Length - 1]);
};
/// <summary>
/// Request headers to be appended to the connection string.
/// </summary>
public readonly Dictionary<string, object> Headers = new();
/// <summary>
/// The optional params to pass when connecting
/// </summary>
public SocketOptionsParameters Parameters = new();
/// <summary>
/// Datetime Style for JSON Deserialization of Models
/// </summary>
public readonly DateTimeStyles DateTimeStyles = DateTimeStyles.AdjustToUniversal;
/// <summary>
/// Datetime format for JSON Deserialization of Models (Postgrest style)
/// </summary>
public string DateTimeFormat { get; set; } = @"yyyy'-'MM'-'dd' 'HH':'mm':'ss.FFFFFFK";
}