Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardcode gateway url #1957

Merged
merged 2 commits into from
Dec 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/main/java/net/dv8tion/jda/api/utils/SessionController.java
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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