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

@ -5,7 +5,12 @@ public interface FlexLibAdapter {
/**
* Called when WebSocket is connected and server responded HELLO
*/
public default void onWebSocketConnect() {}
public default void onWebSocketConnect() {}
/**
* Called when WebSocket is disconnected
*/
public default void onWebSocketDisconnect() {}
/**
* Called when player friend list or friend requests are updated

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 {