Package net.dv8tion.jda.api.utils
Class SessionControllerAdapter
- java.lang.Object
-
- net.dv8tion.jda.api.utils.SessionControllerAdapter
-
- All Implemented Interfaces:
SessionController
- Direct Known Subclasses:
ConcurrentSessionController
public class SessionControllerAdapter extends java.lang.Object implements SessionController
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.dv8tion.jda.api.utils.SessionController
SessionController.SessionConnectNode, SessionController.ShardedGateway
-
-
Field Summary
-
Fields inherited from interface net.dv8tion.jda.api.utils.SessionController
IDENTIFY_DELAY
-
-
Constructor Summary
Constructors Constructor Description SessionControllerAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
appendSession(SessionController.SessionConnectNode node)
Called by a JDA session when a WebSocket should be started.java.lang.String
getGateway(JDA api)
Called by a JDA session when a new gateway session starts (Connecting, Reconnecting).net.dv8tion.jda.internal.utils.tuple.Pair<java.lang.String,java.lang.Integer>
getGatewayBot(JDA api)
Called byDefaultShardManager
when a new shards is starting.long
getGlobalRatelimit()
Provides the cross-session global REST ratelimit it received throughSessionController.setGlobalRatelimit(long)
.SessionController.ShardedGateway
getShardedGateway(JDA api)
Called byDefaultShardManager
when a new shards is starting.void
removeSession(SessionController.SessionConnectNode node)
Called by a JDA session when a shutdown has been requested.void
setGlobalRatelimit(long ratelimit)
Called by the RateLimiter if the global rest ratelimit has changed.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.dv8tion.jda.api.utils.SessionController
setConcurrency
-
-
-
-
Method Detail
-
appendSession
public void appendSession(@Nonnull SessionController.SessionConnectNode node)
Description copied from interface:SessionController
Called 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:
appendSession
in interfaceSessionController
- Parameters:
node
- TheSessionConnectNode
-
removeSession
public void removeSession(@Nonnull SessionController.SessionConnectNode node)
Description copied from interface:SessionController
Called 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:
removeSession
in interfaceSessionController
- Parameters:
node
- TheSessionConnectNode
to remove from the queue.
-
getGlobalRatelimit
public long getGlobalRatelimit()
Description copied from interface:SessionController
Provides the cross-session global REST ratelimit it received throughSessionController.setGlobalRatelimit(long)
.- Specified by:
getGlobalRatelimit
in interfaceSessionController
- Returns:
- The current global REST ratelimit or -1 if unset
-
setGlobalRatelimit
public void setGlobalRatelimit(long ratelimit)
Description copied from interface:SessionController
Called by the RateLimiter if the global rest ratelimit has changed.- Specified by:
setGlobalRatelimit
in interfaceSessionController
- Parameters:
ratelimit
- The new global ratelimit
-
getGateway
@Nonnull public java.lang.String getGateway(@Nonnull JDA api)
Description copied from interface:SessionController
Called by a JDA session when a new gateway session starts (Connecting, Reconnecting).
Should provide the gateway endpoint (wss) to connect to.- Specified by:
getGateway
in interfaceSessionController
- Parameters:
api
- The current JDA instance (used for RestActions and ShardInfo)- Returns:
- The gateway endpoint
-
getShardedGateway
@Nonnull public SessionController.ShardedGateway getShardedGateway(@Nonnull JDA api)
Description copied from interface:SessionController
Called byDefaultShardManager
when a new shards is starting.
Should provide aSessionController.ShardedGateway
with(gateway, shardTotal)
.- Specified by:
getShardedGateway
in interfaceSessionController
- Parameters:
api
- The current JDA instance (used for RestActions and ShardInfo)- Returns:
- The ShardedGateway instance consisting of the gateway endpoint to connect to and the shardTotal
- See Also:
SessionController.getGateway(net.dv8tion.jda.api.JDA)
-
getGatewayBot
@Nonnull public net.dv8tion.jda.internal.utils.tuple.Pair<java.lang.String,java.lang.Integer> getGatewayBot(@Nonnull JDA api)
Description copied from interface:SessionController
Called byDefaultShardManager
when a new shards is starting.
Should provide aPair
with(gateway, shardTotal)
.- Specified by:
getGatewayBot
in interfaceSessionController
- Parameters:
api
- The current JDA instance (used for RestActions and ShardInfo)- Returns:
- The Pair consisting of the gateway endpoint to connect to and the shardTotal
- See Also:
SessionController.getGateway(net.dv8tion.jda.api.JDA)
-
-