Table of Contents

Class KookSocketConfig

Namespace
Kook.WebSocket
Assembly
Kook.Net.WebSocket.dll

Represents a configuration class for KookSocketClient.

public class KookSocketConfig : KookRestConfig
Inheritance
KookSocketConfig
Inherited Members

Examples

The following config enables the message cache and configures the client to always download user upon guild availability.

var config = new KookSocketConfig
{
    AlwaysDownloadUsers = true,
    MessageCacheSize = 100
};
var client = new KookSocketClient(config);

Remarks

This configuration, based on KookRestConfig, helps determine several key configurations the socket client depend on. For instance, message cache and connection timeout.

Constructors

KookSocketConfig()

Initializes a new instance of the KookSocketConfig class.

public KookSocketConfig()

Fields

GatewayEncoding

Returns the encoding gateway should use.

public const string GatewayEncoding = "json"

Field Value

string

HeartbeatIntervalMilliseconds

Gets the heartbeat interval of WebSocket connection in milliseconds.

public const int HeartbeatIntervalMilliseconds = 30000

Field Value

int

RtcpIntervalMilliseconds

Gets the RTCP interval of RTP connection in milliseconds.

public const int RtcpIntervalMilliseconds = 5000

Field Value

int

Properties

AlwaysDownloadBoostSubscriptions

Gets or sets whether or not all boost subscriptions should be downloaded as guilds come available.

public bool AlwaysDownloadBoostSubscriptions { get; set; }

Property Value

bool

Remarks

note

Setting this property to true will cause the client to download all boost subscriptions for all guilds upon startup and when GuildUpdated is triggered with changes occurring to BoostSubscriptionCount. Please note that it can be difficult to fill the cache completely on large guilds depending on the traffic. If you are experiencing issues, try setting this to false and manually call DownloadBoostSubscriptionsAsync(IEnumerable<IGuild>?, RequestOptions?) on the guilds you want.

AlwaysDownloadUsers

Gets or sets whether or not all users should be downloaded as guilds come available.

public bool AlwaysDownloadUsers { get; set; }

Property Value

bool

Remarks

note

Setting this property to true will cause the client to download all users for all guilds upon startup. Please note that it can be difficult to fill the cache completely on large guilds depending on the traffic. If you are experiencing issues, try setting this to false and manually call DownloadUsersAsync(IEnumerable<IGuild>?, RequestOptions?) on the guilds you want.

AlwaysDownloadVoiceStates

Gets or sets whether or not all voice states should be downloaded as guilds come available.

public bool AlwaysDownloadVoiceStates { get; set; }

Property Value

bool

Remarks

note

Setting this property to true will cause the client to download all voice states for all guilds upon startup. Please note that it can be difficult to fill the cache completely on large guilds depending on the traffic. If you are experiencing issues, try setting this to false and manually call DownloadVoiceStatesAsync(IEnumerable<IGuild>?, RequestOptions?) on the guilds you want.

AutoUpdateChannelPositions

Gets or sets whether to update guild channels via API when gateway publishes sort_channel events.

public bool AutoUpdateChannelPositions { get; set; }

Property Value

bool

AutoUpdateRolePositions

Gets or sets whether to update guild role positions via API when GuildUpdated fires.

public bool AutoUpdateRolePositions { get; set; }

Property Value

bool

ConnectionTimeout

Gets or sets the time, in milliseconds, to wait for a connection to complete before aborting.

public int ConnectionTimeout { get; set; }

Property Value

int

GatewayHost

Gets or sets the WebSocket host to connect to. If null, the client will use the /gateway endpoint.

public string? GatewayHost { get; set; }

Property Value

string

HandlerTimeout

Gets or sets the timeout for event handlers, in milliseconds, after which a warning will be logged. Setting this property to nulldisables this check.

public int? HandlerTimeout { get; set; }

Property Value

int?

JoinedGuildDataFetchingRetryDelay

Gets or sets the delay in milliseconds between each retry of fetching joined guild data.

public int JoinedGuildDataFetchingRetryDelay { get; set; }

Property Value

int

Exceptions

ArgumentException

Value must be at least 0.

MaxJoinedGuildDataFetchingRetryTimes

Gets or sets the maximum number of times to retry fetching joined guild data.

public int MaxJoinedGuildDataFetchingRetryTimes { get; set; }

Property Value

int

Remarks

Due to the KOOK API cannot return the newly joined guilds immediately well, this property is used to control the maximum number of times to retry fetching joined guild data. Each retry will be delayed by JoinedGuildDataFetchingRetryDelay milliseconds. Set to 0 or negative value to disable retrying.

MaxWaitBetweenGuildAvailablesBeforeReady

Gets or sets the maximum wait time in milliseconds between GUILD_AVAILABLE events before firing READY. If zero, READY will fire as soon as it is received and all guilds will be unavailable.

public int MaxWaitBetweenGuildAvailablesBeforeReady { get; set; }

Property Value

int

An int representing the maximum wait time in milliseconds between GUILD_AVAILABLE events before firing READY.

Remarks

This property is measured in milliseconds; negative values will throw an exception.

If a guild is not received before READY, it will be unavailable.

Exceptions

ArgumentException

Value must be at least 0.

MessageCacheSize

Gets or sets the number of messages per channel that should be kept in cache. Setting this to zero disables the message cache entirely.

public int MessageCacheSize { get; set; }

Property Value

int

UdpSocketProvider

Gets or sets the provider used to generate new UDP sockets.

public UdpSocketProvider UdpSocketProvider { get; set; }

Property Value

UdpSocketProvider

WebSocketProvider

Gets or sets the provider used to generate new WebSocket connections.

public WebSocketProvider WebSocketProvider { get; set; }

Property Value

WebSocketProvider