Skip to content

Commit

Permalink
Hardcode gateway url (#1957)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xirado committed Dec 24, 2021
1 parent 56bef05 commit 11bbb83
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
13 changes: 7 additions & 6 deletions src/main/java/net/dv8tion/jda/api/utils/SessionController.java
Expand Up @@ -138,16 +138,17 @@ default void setConcurrency(int level) {}
void setGlobalRatelimit(long ratelimit);

/**
* Called by a JDA session when a new gateway session starts (Connecting, Reconnecting).
* <br>Should provide the gateway endpoint (wss) to connect to.
* Discord's gateway URL, which is used to receive events.
*
* @param api
* The current JDA instance (used for RestActions and ShardInfo)
* Called by JDA when starting a new gateway session (Connecting, Reconnecting).
*
* @return The gateway endpoint
*/
@Nonnull
String getGateway(@Nonnull JDA api);
default String getGateway()
{
return "wss://gateway.discord.gg/";
}

/**
* Called by {@link net.dv8tion.jda.api.sharding.DefaultShardManager DefaultShardManager}
Expand All @@ -159,7 +160,7 @@ default void setConcurrency(int level) {}
*
* @return The ShardedGateway instance consisting of the gateway endpoint to connect to and the shardTotal
*
* @see #getGateway(net.dv8tion.jda.api.JDA)
* @see #getGateway()
*/
@Nonnull
ShardedGateway getShardedGateway(@Nonnull JDA api);
Expand Down
Expand Up @@ -76,15 +76,6 @@ public void setGlobalRatelimit(long ratelimit)
globalRatelimit.set(ratelimit);
}

@Nonnull
@Override
public String getGateway(@Nonnull JDA api)
{
Route.CompiledRoute route = Route.Misc.GATEWAY.compile();
return new RestActionImpl<String>(api, route,
(response, request) -> response.getObject().getString("url")).priority().complete();
}

@Nonnull
@Override
public ShardedGateway getShardedGateway(@Nonnull JDA api)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/dv8tion/jda/internal/JDAImpl.java
Expand Up @@ -318,7 +318,7 @@ public int login(String gatewayUrl, ShardInfo shardInfo, Compression compression

public String getGateway()
{
return getSessionController().getGateway(this);
return getSessionController().getGateway();
}


Expand Down

0 comments on commit 11bbb83

Please sign in to comment.