Class ConcurrentSessionController
- All Implemented Interfaces:
- SessionController
SessionController which respects concurrent shard login.
 This makes use of the
setConcurrency(int) hook to delegate buckets for individual shard queues.
 The concurrency model works through a modulo over the concurrency limit.
bucket = shard_id % concurrencyThis implementation is rather naive. It will use one thread per bucket and use sleeps to backoff. If desired, this could be done a lot more efficiently by using a scheduler. However, it is rather unlikely to be an issue in most cases. The only time where 64 threads would actually be used is during the initial startup. During runtime its not common for all shards to reconnect at once.
- 
Nested Class SummaryNested classes/interfaces inherited from interface net.dv8tion.jda.api.utils.SessionControllerSessionController.SessionConnectNode, SessionController.ShardedGateway
- 
Field SummaryFields inherited from interface net.dv8tion.jda.api.utils.SessionControllerIDENTIFY_DELAY
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidCalled by a JDA session when a WebSocket should be started.voidCalled by a JDA session when a shutdown has been requested.voidsetConcurrency(int level) Apply themax_concurrencyfor this bot.Methods inherited from class net.dv8tion.jda.api.utils.SessionControllerAdaptergetRateLimitHandle, getShardedGatewayMethods inherited from class java.lang.Objectequals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.dv8tion.jda.api.utils.SessionControllergetGateway, getRateLimitHandle, getShardedGateway
- 
Constructor Details- 
ConcurrentSessionControllerpublic ConcurrentSessionController()
 
- 
- 
Method Details- 
setConcurrencypublic void setConcurrency(int level) Description copied from interface:SessionControllerApply themax_concurrencyfor this bot. This property is only useful for very large bots which get access to higher concurrency when starting their shards.Currently, there are 3 different levels of concurrency 1, 16, and 64. The concurrency means the bot can connect multiple shards at once without hitting the IDENTIFY rate-limit. This works by applying the concurrency level as a modulo operand to the shard id: shard_id % concurrency. We use one thread per bucket in this implementation.An implementation of this interface is not required to use this concurrency level. SessionControllerAdapterdoes not support this due to backwards compatibility.- Specified by:
- setConcurrencyin interface- SessionController
- Parameters:
- level- The concurrency level
 
- 
appendSessionDescription copied from interface:SessionControllerCalled by a JDA session when a WebSocket should be started. (Connecting and Reconnecting)
 This should only add the node to a queue and execute the queue with respect to theSessionController.IDENTIFY_DELAY.- Specified by:
- appendSessionin interface- SessionController
- Overrides:
- appendSessionin class- SessionControllerAdapter
- Parameters:
- node- The- SessionConnectNode
 
- 
removeSessionDescription copied from interface:SessionControllerCalled by a JDA session when a shutdown has been requested.
 When this happened theSessionConnectNode.run(boolean)will be a no-op and does not contribute to theSessionController.IDENTIFY_DELAY.- Specified by:
- removeSessionin interface- SessionController
- Overrides:
- removeSessionin class- SessionControllerAdapter
- Parameters:
- node- The- SessionConnectNodeto remove from the queue.
 
 
-