Add handler for HELLO websocket message

This commit is contained in:
Jonttuuu 2023-07-30 15:15:55 +03:00
parent 651700ca62
commit 76aad82883
3 changed files with 14 additions and 0 deletions

View File

@ -2,6 +2,11 @@ package fi.flexplex.lib;
public interface FlexLibAdapter { 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 * Called when player friend list or friend requests are updated
* @param player * @param player

View File

@ -14,4 +14,9 @@ public final class FlexLibAdapterImpl implements FlexLibAdapter {
this.flexLib.updatePlayerFriends(player); this.flexLib.updatePlayerFriends(player);
} }
@Override
public void onWebSocketConnect() {
this.flexLib.getLogger().info("WebSocket connected");
}
} }

View File

@ -76,6 +76,10 @@ public final class WebSocketClient {
} }
} }
break; break;
case "HELLO":
for (final FlexLibAdapter listener : flexLib.getEventListeners()) {
listener.onWebSocketConnect();
}
default: default:
flexLib.getLogger().warning("Received invalid WebSocket message from FlexPlex. Message: " + args[0]); flexLib.getLogger().warning("Received invalid WebSocket message from FlexPlex. Message: " + args[0]);
break; break;