Klasse TwitchChatConnectionPool
- Alle implementierten Schnittstellen:
ITwitchChat,TransactionalSubscriber<String,,String, Boolean> AutoCloseable
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
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.
-
Verschachtelte Klassen - Übersicht
Verschachtelte KlassenModifizierer und TypKlasseBeschreibungstatic classTwitchChatConnectionPool.TwitchChatConnectionPoolBuilder<C extends TwitchChatConnectionPool,B extends TwitchChatConnectionPool.TwitchChatConnectionPoolBuilder<C, B>> Von Klasse geerbte verschachtelte Klassen/Schnittstellen com.github.twitch4j.common.pool.TwitchModuleConnectionPool
TwitchModuleConnectionPool.TwitchModuleConnectionPoolBuilder<C,X, Y, Z, B, C2 extends TwitchModuleConnectionPool<C, X, Y, Z, B>, B2 extends TwitchModuleConnectionPool.TwitchModuleConnectionPoolBuilder<C, X, Y, Z, B, C2, B2>> Von Klasse geerbte verschachtelte Klassen/Schnittstellen com.github.twitch4j.common.pool.SubscriptionConnectionPool
SubscriptionConnectionPool.SubscriptionConnectionPoolBuilder<C,S, T, U, C2 extends SubscriptionConnectionPool<C, S, T, U>, B extends SubscriptionConnectionPool.SubscriptionConnectionPoolBuilder<C, S, T, U, C2, B>> Von Klasse geerbte verschachtelte Klassen/Schnittstellen com.github.twitch4j.common.pool.AbstractConnectionPool
AbstractConnectionPool.AbstractConnectionPoolBuilder<C,C2 extends AbstractConnectionPool<C>, B extends AbstractConnectionPool.AbstractConnectionPoolBuilder<C, C2, B>> -
Feldübersicht
FelderModifizierer und TypFeldBeschreibungprotected BandwidthCustom RateLimit for AUTHprotected final booleanVeraltet.use removeChannelOnJoinFailure via advancedConfiguration instead.protected final @NonNull Supplier<OAuth2Credential> Provides a chat account to be used when constructing a newTwitchChatinstance.protected BandwidthCustom RateLimit for ChatMessagesprotected BandwidthCustom RateLimit for JOIN/PARTprotected BandwidthCustom RateLimit for Messages per Channelprotected Bandwidth[]Custom RateLimit for WhispersVon Klasse geerbte Felder com.github.twitch4j.common.pool.TwitchModuleConnectionPool
advancedConfiguration, executor, proxyConfigVon Klasse geerbte Felder com.github.twitch4j.common.pool.SubscriptionConnectionPool
closed, disposeUnusedConnections, maxSubscriptionsPerConnection, saturatedConnections, subscriptions, unsaturatedConnections -
Konstruktorübersicht
KonstruktorenModifiziererKonstruktorBeschreibungprotected -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungbuilder()protected TwitchChatprotected voiddisposeConnection(TwitchChat connection) Note: this map does not dynamically update unlikeTwitchChat.getChannelIdToChannelName()Note: this map does not dynamically update unlikeTwitchChat.getChannelNameToChannelId()Returns a set of all currently joined channels (without # prefix)longprotected Stringprotected intprotected StringhandleDuplicateSubscription(TwitchChat twitchChat, TwitchChat old, String s) protected StringhandleSubscription(TwitchChat twitchChat, String s) protected BooleanhandleUnsubscription(TwitchChat twitchChat, String s) booleanisChannelJoined(String channelName) Check if Chat is currently in a channelvoidjoinChannel(String channelName) Joins a channelbooleanleaveChannel(String channelName) Parts from a channelbooleansendMessage(String channelToIdentifyChatInstance, String targetChannel, String message) Sends a message from theTwitchChatidentified either to a channel or directly on the socket.booleansendMessage(String channelToIdentifyChatInstance, String targetChannel, String message, String nonce, String replyMsgId) Sends a message from the identifiedTwitchChatinstance with an optional nonce or reply parent.booleansendMessage(String channelToIdentifyChatInstance, String targetChannel, String message, @Nullable Map<String, Object> tags) Sends a message from the identifiedTwitchChatinstance with the specified tags.booleanSends a message to the channel while including the specified message tags.booleansendPrivateMessage(String channelToIdentifyChatInstance, String toChannel, String message) Veraltet.Twitch will decommission this method on February 18, 2023; migrate to TwitchHelix#updateChatSettingsJoins a channel.Parts from a channel.Von Klasse geerbte Methoden com.github.twitch4j.common.pool.TwitchModuleConnectionPool
getConnectionEventManager, getDefaultConnectionEventManager, getEventManager, getExecutorVon Klasse geerbte Methoden com.github.twitch4j.common.pool.SubscriptionConnectionPool
close, getConnections, numConnections, numSubscriptionsVon Klasse geerbte Methoden java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitVon Schnittstelle geerbte Methoden com.github.twitch4j.chat.ITwitchChat
ban, clearChat, close, delete, getEventManager, sendActionMessage, sendAnnouncement, sendMessage, sendMessage, setEmoteOnly, setFollowersOnly, setSlowMode, setSubscribersOnly, setUniqueChat, timeout, unban
-
Felddetails
-
chatAccount
Provides a chat account to be used when constructing a newTwitchChatinstance. By default, this yields null, which corresponds to an anonymous connection. -
automaticallyPartOnBan
Veraltet.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
Custom RateLimit for ChatMessages -
whisperRateLimit
Custom RateLimit for Whispers -
joinRateLimit
Custom RateLimit for JOIN/PART -
authRateLimit
Custom RateLimit for AUTH -
perChannelRateLimit
Custom RateLimit for Messages per ChannelFor example, this can restrict messages per channel at 100/30 (for a verified bot that has a global 7500/30 message limit).
-
-
Konstruktordetails
-
TwitchChatConnectionPool
-
-
Methodendetails
-
sendMessage
public boolean sendMessage(String channel, String message, @Nullable @Nullable Map<String, Object> tags) Beschreibung aus Schnittstelle kopiert:ITwitchChatSends a message to the channel while including the specified message tags.- Angegeben von:
sendMessagein SchnittstelleITwitchChat- Parameter:
channel- the name of the channel to send the message to.message- the message to be sent.tags- the message tags.- Gibt zurück:
- whether the message was added to the queue
-
sendMessage
public boolean sendMessage(String channelToIdentifyChatInstance, String targetChannel, String message) Sends a message from theTwitchChatidentified either to a channel or directly on the socket.- Parameter:
channelToIdentifyChatInstance- the channel used to identify whichTwitchChatinstance should be used to send the message; the instance must be subscribed to this channel.targetChannel- the channel to send the message to, if not null (otherwise it is sent directly on the socket).message- the message to be sent.- Gibt zurück:
- whether a
TwitchChatinstance was found and used to send the message
-
sendMessage
public boolean sendMessage(String channelToIdentifyChatInstance, String targetChannel, String message, @Unofficial String nonce, String replyMsgId) Sends a message from the identifiedTwitchChatinstance with an optional nonce or reply parent.- Parameter:
channelToIdentifyChatInstance- the channel used to identify whichTwitchChatinstance should be used to send the message; the instance must be subscribed to this channel.targetChannel- the channel to send the message to, if not null (otherwise it is sent directly on the socket).message- the message to be sent.nonce- the cryptographic nonce (optional).replyMsgId- the msgId of the parent message being replied to (optional).- Gibt zurück:
- whether a
TwitchChatinstance was found and used to send the message
-
sendMessage
public boolean sendMessage(String channelToIdentifyChatInstance, String targetChannel, String message, @Nullable @Nullable Map<String, Object> tags) Sends a message from the identifiedTwitchChatinstance with the specified tags.- Parameter:
channelToIdentifyChatInstance- the channel used to identify whichTwitchChatinstance should be used to send the message; the instance must be subscribed to this channel.targetChannel- the channel to send the message to, if not null (otherwise it is sent directly on the socket).message- the message to be sent.tags- the message tags.- Gibt zurück:
- whether a
TwitchChatinstance was found and used to send the message
-
sendPrivateMessage
@Deprecated public boolean sendPrivateMessage(String channelToIdentifyChatInstance, String toChannel, String message) Veraltet.Twitch will decommission this method on February 18, 2023; migrate to TwitchHelix#updateChatSettingsSends a whisper.- Parameter:
channelToIdentifyChatInstance- the channel used to identify whichTwitchChatinstance should be used to send the message; the instance must be subscribed to this channel.toChannel- the channel to send the whisper to.message- the message to send in the whisper.- Gibt zurück:
- whether a
TwitchChatinstance was identified to send the message from. - Löst aus:
NullPointerException- if the identifiedTwitchChatdoes not have a valid chatCredential
-
subscribe
Joins a channel.- Angegeben von:
subscribein SchnittstelleTransactionalSubscriber<String,String, Boolean> - Setzt außer Kraft:
subscribein KlasseSubscriptionConnectionPool<TwitchChat,String, String, Boolean> - Parameter:
s- the channel name- Gibt zurück:
- the channel name
-
joinChannel
Beschreibung aus Schnittstelle kopiert:ITwitchChatJoins a channel- Angegeben von:
joinChannelin SchnittstelleITwitchChat- Parameter:
channelName- The target channel name.
-
unsubscribe
Parts from a channel.- Angegeben von:
unsubscribein SchnittstelleTransactionalSubscriber<String,String, Boolean> - Setzt außer Kraft:
unsubscribein KlasseSubscriptionConnectionPool<TwitchChat,String, String, Boolean> - Parameter:
s- the channel name- Gibt zurück:
- a non-null class if able to part, null otherwise
-
leaveChannel
Beschreibung aus Schnittstelle kopiert:ITwitchChatParts from a channel- Angegeben von:
leaveChannelin SchnittstelleITwitchChat- Parameter:
channelName- The target channel name.- Gibt zurück:
- whether the channel was previously joined
-
isChannelJoined
Beschreibung aus Schnittstelle kopiert:ITwitchChatCheck if Chat is currently in a channel- Angegeben von:
isChannelJoinedin SchnittstelleITwitchChat- Parameter:
channelName- channel to check (without # prefix)- Gibt zurück:
- boolean
-
getChannels
Beschreibung aus Schnittstelle kopiert:ITwitchChatReturns a set of all currently joined channels (without # prefix)- Angegeben von:
getChannelsin SchnittstelleITwitchChat- Gibt zurück:
- a set of channel names
-
handleSubscription
- Angegeben von:
handleSubscriptionin KlasseSubscriptionConnectionPool<TwitchChat,String, String, Boolean>
-
handleDuplicateSubscription
- Angegeben von:
handleDuplicateSubscriptionin KlasseSubscriptionConnectionPool<TwitchChat,String, String, Boolean>
-
handleUnsubscription
- Angegeben von:
handleUnsubscriptionin KlasseSubscriptionConnectionPool<TwitchChat,String, String, Boolean>
-
getRequestFromSubscription
- Angegeben von:
getRequestFromSubscriptionin KlasseSubscriptionConnectionPool<TwitchChat,String, String, Boolean>
-
getSubscriptionSize
- Angegeben von:
getSubscriptionSizein KlasseSubscriptionConnectionPool<TwitchChat,String, String, Boolean>
-
createConnection
- Angegeben von:
createConnectionin KlasseAbstractConnectionPool<TwitchChat>
-
disposeConnection
- Angegeben von:
disposeConnectionin KlasseAbstractConnectionPool<TwitchChat>
-
getLatency
public long getLatency()- Angegeben von:
getLatencyin SchnittstelleITwitchChat- Gibt zurück:
- the most recently measured round-trip latency for the socket(s) in milliseconds, or -1 if unknown
-
getChannelIdToChannelName
Note: this map does not dynamically update unlikeTwitchChat.getChannelIdToChannelName()- Angegeben von:
getChannelIdToChannelNamein SchnittstelleITwitchChat- Gibt zurück:
- cached mappings of channel ids to names
-
getChannelNameToChannelId
Note: this map does not dynamically update unlikeTwitchChat.getChannelNameToChannelId()- Angegeben von:
getChannelNameToChannelIdin SchnittstelleITwitchChat- Gibt zurück:
- cached mappings of channel names to ids
-
builder
-