// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/ChatEventPublisher.java
// @Slf4j
// @Service
// public class ChatEventPublisher {
// 
//     private final RedisTemplate<String, Object> messageRedisTemplate;
//     private final Topic topic;
// 
//     @Autowired
//     public ChatEventPublisher(final RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("chatTopic") final Topic topic) {
//         this.messageRedisTemplate = messageRedisTemplate;
//         this.topic = topic;
//     }
// 
//     public void publish(final ChatMessage chatMessage) {
//         log.info("Sending ChatMessage " + chatMessage);
//         this.messageRedisTemplate.convertAndSend(topic.getTopic(), chatMessage);
//     }
// }
// 
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/GameEventPublisher.java
// @Slf4j
// @Service
// public class GameEventPublisher {
// 
//     private final RedisTemplate<String, Object> messageRedisTemplate;
//     private final Topic topic;
// 
//     @Autowired
//     public GameEventPublisher(RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("gameTopic") Topic topic) {
//         this.messageRedisTemplate = messageRedisTemplate;
//         this.topic = topic;
//     }
// 
//     public void publish(final GameMessage gameMessage) {
//         log.info("Sending GameMessage " + gameMessage);
//         messageRedisTemplate.convertAndSend(topic.getTopic(), gameMessage);
//     }
// }
// 
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/ChatMessage.java
// @Getter
// @Builder
// @AllArgsConstructor
// public class ChatMessage implements Serializable {
// 
//     private String message;
//     private String username;
// 
// }
// 
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/GameMessage.java
// @Getter
// @Builder
// @NoArgsConstructor
// @AllArgsConstructor
// public class GameMessage implements Serializable {
// 
//     private Game game;
// 
//     private GameEvent event;
// 
//     private String username;
// 
//     private String image;
// 
//     public static GameMessageBuilder of(GameMessage gameMessage) {
//         return GameMessage.builder()
//                 .event(gameMessage.getEvent())
//                 .game(gameMessage.getGame())
//                 .image(gameMessage.getImage())
//                 .username(gameMessage.getUsername());
//     }
// }


import be.ordina.jworks.rpsls.game.*;
import be.ordina.jworks.rpsls.game.pubsub.ChatEventPublisher;
import be.ordina.jworks.rpsls.game.pubsub.GameEventPublisher;
import be.ordina.jworks.rpsls.game.websocket.ChatMessage;
import be.ordina.jworks.rpsls.game.websocket.GameMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.security.Principal;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import static org.springframework.util.Assert.notNull;
package be.ordina.jworks.rpsls.controller;




@Slf4j
@RestController
public class GameController {

    private final GameRepository gameRepository;
    private final GameLogic gameLogic;
    private final ChatEventPublisher chatEventPublisher;
    private final GameEventPublisher gameEventPublisher;

    @Autowired
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/ChatEventPublisher.java
// @Slf4j
// @Service
// public class ChatEventPublisher {
// 
//     private final RedisTemplate<String, Object> messageRedisTemplate;
//     private final Topic topic;
// 
//     @Autowired
//     public ChatEventPublisher(final RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("chatTopic") final Topic topic) {
//         this.messageRedisTemplate = messageRedisTemplate;
//         this.topic = topic;
//     }
// 
//     public void publish(final ChatMessage chatMessage) {
//         log.info("Sending ChatMessage " + chatMessage);
//         this.messageRedisTemplate.convertAndSend(topic.getTopic(), chatMessage);
//     }
// }
// 
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/pubsub/GameEventPublisher.java
// @Slf4j
// @Service
// public class GameEventPublisher {
// 
//     private final RedisTemplate<String, Object> messageRedisTemplate;
//     private final Topic topic;
// 
//     @Autowired
//     public GameEventPublisher(RedisTemplate<String, Object> messageRedisTemplate, @Qualifier("gameTopic") Topic topic) {
//         this.messageRedisTemplate = messageRedisTemplate;
//         this.topic = topic;
//     }
// 
//     public void publish(final GameMessage gameMessage) {
//         log.info("Sending GameMessage " + gameMessage);
//         messageRedisTemplate.convertAndSend(topic.getTopic(), gameMessage);
//     }
// }
// 
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/ChatMessage.java
// @Getter
// @Builder
// @AllArgsConstructor
// public class ChatMessage implements Serializable {
// 
//     private String message;
//     private String username;
// 
// }
// 
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/game/websocket/GameMessage.java
// @Getter
// @Builder
// @NoArgsConstructor
// @AllArgsConstructor
// public class GameMessage implements Serializable {
// 
//     private Game game;
// 
//     private GameEvent event;
// 
//     private String username;
// 
//     private String image;
// 
//     public static GameMessageBuilder of(GameMessage gameMessage) {
//         return GameMessage.builder()
//                 .event(gameMessage.getEvent())
//                 .game(gameMessage.getGame())
//                 .image(gameMessage.getImage())
//                 .username(gameMessage.getUsername());
//     }
// }


// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/controller/GameController.java
import be.ordina.jworks.rpsls.game.*;
import be.ordina.jworks.rpsls.game.pubsub.ChatEventPublisher;
import be.ordina.jworks.rpsls.game.pubsub.GameEventPublisher;
import be.ordina.jworks.rpsls.game.websocket.ChatMessage;
import be.ordina.jworks.rpsls.game.websocket.GameMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.security.Principal;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import static org.springframework.util.Assert.notNull;

package be.ordina.jworks.rpsls.controller;




@Slf4j
@RestController
public class GameController {

    private final GameRepository gameRepository;
    private final GameLogic gameLogic;
    private final ChatEventPublisher chatEventPublisher;
    private final GameEventPublisher gameEventPublisher;

    @Autowired
    public GameController(final GameRepository gameRepository, final GameLogic gameLogic, ChatEventPublisher chatEventPublisher, final GameEventPublisher gameEventPublisher) {