public DefaultGatewayClient( IOptions <DefaultGatewayClientConfiguration> options, ILogger <DefaultGatewayClient> logger, IGatewayCacheProvider cacheProvider, IGatewayChunker chunker, IGatewayDispatcher dispatcher, IGatewayApiClient apiClient) { Logger = logger; CacheProvider = cacheProvider; CacheProvider.Bind(this); Chunker = chunker; Chunker.Bind(this); Dispatcher = dispatcher; if (apiClient != null) { _apiClient = apiClient; Shards = new Dictionary <ShardId, IGatewayApiClient>(1) { [new ShardId(0, 1)] = apiClient }.ReadOnly(); apiClient.DispatchReceived += Dispatcher.HandleDispatchAsync; } else { Shards = new SynchronizedDictionary <ShardId, IGatewayApiClient>(); } Dispatcher.Bind(this); }
public DefaultGatewayClient( IOptions <DefaultGatewayClientConfiguration> options, ILogger <DefaultGatewayClient> logger, IGatewayCacheProvider cacheProvider, IGatewayChunker chunker, IGatewayDispatcher dispatcher) : this(options, logger, cacheProvider, chunker, dispatcher, null) { // This is the constructor DiscordClientSharder uses. }
/// <inheritdoc cref="TryGetUsers"/> /// <summary> /// Attempts to get the messages cache from this cache provider. /// </summary> public static bool TryGetMessages(this IGatewayCacheProvider cacheProvider, Snowflake channelId, out ISynchronizedDictionary <Snowflake, CachedUserMessage> cache, bool lookupOnly = false) => cacheProvider.TryGetCache(channelId, out cache, lookupOnly);
/// <inheritdoc cref="TryGetUsers"/> /// <summary> /// Attempts to get the stages cache from this cache provider. /// </summary> public static bool TryGetStages(this IGatewayCacheProvider cacheProvider, Snowflake guildId, out ISynchronizedDictionary <Snowflake, CachedStage> cache, bool lookupOnly = false) => cacheProvider.TryGetCache(guildId, out cache, lookupOnly);
/// <inheritdoc cref="TryGetUsers"/> /// <summary> /// Attempts to get the guilds cache from this cache provider. /// </summary> public static bool TryGetGuilds(this IGatewayCacheProvider cacheProvider, out ISynchronizedDictionary <Snowflake, CachedGuild> cache) => cacheProvider.TryGetCache(out cache);
/// <summary> /// Attempts to get the users cache from this cache provider. /// </summary> /// <param name="cacheProvider"> The cache provider to retrieve the cache from. </param> /// <param name="cache"> The given cache. </param> /// <returns> /// <see langword="true"/> if the cache exists. /// </returns> public static bool TryGetUsers(this IGatewayCacheProvider cacheProvider, out ISynchronizedDictionary <Snowflake, CachedSharedUser> cache) => cacheProvider.TryGetCache(out cache);