Skip to content

Commit 41fbe33

Browse files
committed
Fix WebSocket connection
1 parent f4ae83f commit 41fbe33

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/main/java/com/exaroton/api/ExarotonClient.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
import org.jetbrains.annotations.NotNull;
1515

1616
import java.io.IOException;
17-
import java.net.*;
17+
import java.net.MalformedURLException;
18+
import java.net.URI;
19+
import java.net.URISyntaxException;
20+
import java.net.URL;
1821
import java.net.http.HttpClient;
1922
import java.net.http.HttpRequest;
2023
import java.net.http.HttpResponse;
@@ -234,11 +237,7 @@ public Server getCurrentServer() {
234237
*/
235238
@ApiStatus.Internal
236239
public WebSocketConnection connectToWebSocket(Server server, String path) {
237-
try {
238-
URL url = new URL("wss", getHost(), getBasePath());
239-
return new WebSocketConnection(httpClient, gson, url.toURI().resolve(path), apiToken, server);
240-
} catch (URISyntaxException | MalformedURLException e) {
241-
throw new RuntimeException(e);
242-
}
240+
URI uri = URI.create("wss://" + getHost() + "/" + getBasePath()).resolve(path);
241+
return new WebSocketConnection(httpClient, gson, uri, apiToken, server);
243242
}
244243
}

0 commit comments

Comments
 (0)