Skip to content

Commit

Permalink
Fix KaraFun Remote export
Browse files Browse the repository at this point in the history
  • Loading branch information
fcrespel committed Oct 1, 2024
1 parent 9510704 commit a59b7ac
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -86,6 +87,8 @@ protected void handleTextMessage(WebSocketSession session, TextMessage message)
@SuppressWarnings("unchecked")
protected KarafunWebSocketMessage handleKarafunMessage(KarafunWebSocketMessage message) {
switch (message.getType()) {
case "core.AuthenticatedEvent":
return buildUpdateUsernameMessage(1, "KaraPlan " + UUID.randomUUID().toString());
case "core.PingRequest":
return new KarafunWebSocketMessage().setId(message.getId()).setType("core.PingResponse");
case "remote.PermissionsUpdateEvent":
Expand Down Expand Up @@ -113,6 +116,12 @@ protected KarafunWebSocketMessage handleKarafunMessage(KarafunWebSocketMessage m
return null;
}

protected KarafunWebSocketMessage buildUpdateUsernameMessage(int index, String username) {
KarafunWebSocketMessage message = new KarafunWebSocketMessage().setId(index + 1).setType("remote.UpdateUsernameRequest");
message.getPayload().put("username", username);
return message;
}

protected KarafunWebSocketMessage buildAddToQueueMessage(int index, long songId) {
KarafunWebSocketMessage message = new KarafunWebSocketMessage().setId(index + 1).setType("remote.AddToQueueRequest");
Map<String, Object> song = new HashMap<>();
Expand Down

0 comments on commit a59b7ac

Please sign in to comment.