WebSocket disconnected event

This commit is contained in:
Jonttuuu 2023-07-30 16:44:43 +03:00
parent b38a3201d3
commit a9c0e24378
3 changed files with 14 additions and 1 deletions

View File

@ -7,6 +7,11 @@ public interface FlexLibAdapter {
*/
public default void onWebSocketConnect() {}
/**
* Called when WebSocket is disconnected
*/
public default void onWebSocketDisconnect() {}
/**
* Called when player friend list or friend requests are updated
* @param player

View File

@ -19,4 +19,9 @@ public final class FlexLibAdapterImpl implements FlexLibAdapter {
this.flexLib.getLogger().info("WebSocket connected");
}
@Override
public void onWebSocketDisconnect() {
this.flexLib.getLogger().info("WebSocket disconnected");
}
}

View File

@ -34,6 +34,9 @@ public final class WebSocketClient {
protected void disable() {
this.webSocket.disconnect();
for (final FlexLibAdapter listener : this.flexLib.getEventListeners()) {
listener.onWebSocketDisconnect();
}
}
private WebSocket createWebSocket(final String url, final String token) throws IOException {