From 2121b397a3c272a65329634f6e6b15ffb41a140a Mon Sep 17 00:00:00 2001 From: Sam Pritchard Date: Tue, 5 Jun 2018 17:13:53 +0100 Subject: [PATCH] Lavalink Major Version Header (#111) * add lavaclient to list of libs which support v3 * testing lavalink version header * change Lavalink-Version to Lavalink-Major-Version * update implementation file to make ppl aware of the change * significant over breaking, removal of non breaking --- IMPLEMENTATION.md | 8 +++++--- .../lavalink/server/config/SentryConfiguration.java | 2 ++ .../src/main/java/lavalink/server/io/SocketServer.java | 10 ++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/IMPLEMENTATION.md b/IMPLEMENTATION.md index 0d6dd9e50..6574137b3 100644 --- a/IMPLEMENTATION.md +++ b/IMPLEMENTATION.md @@ -12,10 +12,12 @@ The Java client has support for JDA, but can also be adapted to work with other * Hixie 76 * Hixie 75 -## Breaking changes v2.0 -> v3.0 -The response of `/loadtracks` has been completely changed. +## Significant changes v2.0 -> v3.0 +* The response of `/loadtracks` has been completely changed. +* Lavalink v3.0 now reports its version as a handshake response header. +`Lavalink-Major-Version` has a value of `3` for v3.0 only. It's missing for any older version. -## Breaking changes v1.3 -> v2.0 +## Significant changes v1.3 -> v2.0 With the release of v2.0 many unnecessary ops were removed: * `connect` diff --git a/LavalinkServer/src/main/java/lavalink/server/config/SentryConfiguration.java b/LavalinkServer/src/main/java/lavalink/server/config/SentryConfiguration.java index e4f1ad48a..51cae187c 100644 --- a/LavalinkServer/src/main/java/lavalink/server/config/SentryConfiguration.java +++ b/LavalinkServer/src/main/java/lavalink/server/config/SentryConfiguration.java @@ -18,7 +18,9 @@ /** * Created by napster on 25.04.18. */ + @Configuration +@SuppressWarnings("WeakerAccess") public class SentryConfiguration { private static final Logger log = LoggerFactory.getLogger(SentryConfiguration.class); diff --git a/LavalinkServer/src/main/java/lavalink/server/io/SocketServer.java b/LavalinkServer/src/main/java/lavalink/server/io/SocketServer.java index f05216948..e22c0849a 100644 --- a/LavalinkServer/src/main/java/lavalink/server/io/SocketServer.java +++ b/LavalinkServer/src/main/java/lavalink/server/io/SocketServer.java @@ -34,7 +34,10 @@ import net.dv8tion.jda.Core; import net.dv8tion.jda.manager.AudioManager; import org.java_websocket.WebSocket; +import org.java_websocket.drafts.Draft; +import org.java_websocket.exceptions.InvalidDataException; import org.java_websocket.handshake.ClientHandshake; +import org.java_websocket.handshake.ServerHandshakeBuilder; import org.java_websocket.server.WebSocketServer; import org.json.JSONObject; import org.slf4j.Logger; @@ -76,6 +79,13 @@ public void start() { super.start(); } + @Override + public ServerHandshakeBuilder onWebsocketHandshakeReceivedAsServer(WebSocket conn, Draft draft, ClientHandshake request) throws InvalidDataException { + ServerHandshakeBuilder builder = super.onWebsocketHandshakeReceivedAsServer(conn, draft, request); + builder.put("Lavalink-Major-Version", "3"); + return builder; + } + @Override public void onOpen(WebSocket webSocket, ClientHandshake clientHandshake) { try {