Skip to content

Commit

Permalink
fix(ws): only allowed 1 ws instance to be activated at once
Browse files Browse the repository at this point in the history
  • Loading branch information
seailz committed Nov 10, 2024
1 parent 800bf95 commit 5ae82a8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/com/seailz/discordjar/ws/WebSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,16 @@ public class WebSocket extends WebSocketListener {
private static byte[] buffer = {};
private static final Inflater inflator = new Inflater();
private boolean open = false;
private static List<WebSocket> webSockets = new ArrayList<>();

public WebSocket(String url, boolean debug) {
this.url = url;
this.debug = debug;
if (webSockets.size() > 1) {
// Close all other websockets
webSockets.forEach(WebSocket::disconnect);
}
webSockets.add(this);
}

public WebsocketAction<Void> connect() {
Expand Down

0 comments on commit 5ae82a8

Please sign in to comment.