Class TwitchChatConnectionPool

All Implemented Interfaces:
ITwitchChat, TransactionalSubscriber<String,String,Boolean>, AutoCloseable

public class TwitchChatConnectionPool extends TwitchModuleConnectionPool<TwitchChat,String,String,Boolean,TwitchChatBuilder> implements ITwitchChat
A pool for TwitchChat connections.

This pool is easiest to use for:

  • Reading from many channels without an account
  • Reading from many channels with an account
  • Reading from many channels using valid proxies
  • Reading and sending messages/whispers with only one account
Other applications are possible, but harder to configure. See below for a list of warnings.

Warning: If a custom ScheduledThreadPoolExecutor is specified, its corePoolSize must be large enough for the threads required by connections made by this class.

Warning: If a chatAccount is to be shared across multiple connections and used to send messages, one should use advancedConfiguration to ensure the two are using a shared Bucket.

Note: If whispers are to be sent using this pool, one must manually join the channel to send the whisper from first. If chatAccount's are dynamically supplied such that no two connections are using the same account, one can set twitchChatBuilder.withAutoJoinOwnChannel(true) via advancedConfiguration to avoid the manual join.

  • Field Details

    • chatAccount

      @NonNull protected final @NonNull Supplier<com.github.philippheuer.credentialmanager.domain.OAuth2Credential> chatAccount
      Provides a chat account to be used when constructing a new TwitchChat instance. By default, this yields null, which corresponds to an anonymous connection.
    • automaticallyPartOnBan

      @Deprecated protected final boolean automaticallyPartOnBan
      Deprecated.
      use removeChannelOnJoinFailure via advancedConfiguration instead.
      Whether chat connections should automatically part from channels they have been banned from. This is useful for reclaiming subscription headroom so a minimal number of chat instances are running. By default false so that a chat instance can (eventually) reconnect if a unban occurs.
    • chatRateLimit

      protected io.github.bucket4j.Bandwidth chatRateLimit
      Custom RateLimit for ChatMessages
    • whisperRateLimit

      protected io.github.bucket4j.Bandwidth[] whisperRateLimit
      Custom RateLimit for Whispers
    • joinRateLimit

      protected io.github.bucket4j.Bandwidth joinRateLimit
      Custom RateLimit for JOIN/PART
    • authRateLimit

      protected io.github.bucket4j.Bandwidth authRateLimit
      Custom RateLimit for AUTH
    • perChannelRateLimit

      protected io.github.bucket4j.Bandwidth perChannelRateLimit
      Custom RateLimit for Messages per Channel

      For example, this can restrict messages per channel at 100/30 (for a verified bot that has a global 7500/30 message limit).

  • Constructor Details

  • Method Details