diff --git a/src/main/java/fi/flexplex/lib/FlexLibAdapter.java b/src/main/java/fi/flexplex/lib/FlexLibAdapter.java index 996a3b1..dbdbe78 100644 --- a/src/main/java/fi/flexplex/lib/FlexLibAdapter.java +++ b/src/main/java/fi/flexplex/lib/FlexLibAdapter.java @@ -2,6 +2,11 @@ package fi.flexplex.lib; public interface FlexLibAdapter { + /** + * Called when WebSocket is connected and server responded HELLO + */ + public default void onWebSocketConnect() {} + /** * Called when player friend list or friend requests are updated * @param player diff --git a/src/main/java/fi/flexplex/lib/FlexLibAdapterImpl.java b/src/main/java/fi/flexplex/lib/FlexLibAdapterImpl.java index abff53e..a3d1766 100644 --- a/src/main/java/fi/flexplex/lib/FlexLibAdapterImpl.java +++ b/src/main/java/fi/flexplex/lib/FlexLibAdapterImpl.java @@ -14,4 +14,9 @@ public final class FlexLibAdapterImpl implements FlexLibAdapter { this.flexLib.updatePlayerFriends(player); } + @Override + public void onWebSocketConnect() { + this.flexLib.getLogger().info("WebSocket connected"); + } + } diff --git a/src/main/java/fi/flexplex/lib/WebSocketClient.java b/src/main/java/fi/flexplex/lib/WebSocketClient.java index 901049d..0d136f8 100644 --- a/src/main/java/fi/flexplex/lib/WebSocketClient.java +++ b/src/main/java/fi/flexplex/lib/WebSocketClient.java @@ -76,6 +76,10 @@ public final class WebSocketClient { } } break; + case "HELLO": + for (final FlexLibAdapter listener : flexLib.getEventListeners()) { + listener.onWebSocketConnect(); + } default: flexLib.getLogger().warning("Received invalid WebSocket message from FlexPlex. Message: " + args[0]); break;