From 9db69f168af6622e989047221eb07022a0c2c4e7 Mon Sep 17 00:00:00 2001 From: Joffrey BION Date: Sun, 22 Jan 2017 12:44:31 +0100 Subject: Ans /user/queue/lobby/joined message on game creation --- .../org/luxons/sevenwonders/controllers/LobbyController.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/org/luxons/sevenwonders/controllers/LobbyController.java b/backend/src/main/java/org/luxons/sevenwonders/controllers/LobbyController.java index 996ea361..80fa12e4 100644 --- a/backend/src/main/java/org/luxons/sevenwonders/controllers/LobbyController.java +++ b/backend/src/main/java/org/luxons/sevenwonders/controllers/LobbyController.java @@ -20,7 +20,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.messaging.handler.annotation.MessageMapping; -import org.springframework.messaging.handler.annotation.SendTo; import org.springframework.messaging.simp.SimpMessagingTemplate; import org.springframework.messaging.simp.annotation.SendToUser; import org.springframework.messaging.simp.annotation.SubscribeMapping; @@ -66,8 +65,8 @@ public class LobbyController { } @MessageMapping("/lobby/create") - @SendTo("/topic/games") - public Collection createGame(@Validated CreateGameAction action, Principal principal) { + @SendToUser("/queue/lobby/joined") + public Lobby createGame(@Validated CreateGameAction action, Principal principal) { checkThatUserIsNotInAGame(principal, "cannot create another game"); Player gameOwner = playerRepository.find(principal.getName()); @@ -76,7 +75,10 @@ public class LobbyController { logger.info("Game '{}' ({}) created by {} ({})", lobby.getName(), lobby.getId(), gameOwner.getDisplayName(), gameOwner.getUsername()); - return Collections.singletonList(lobby); + + // notify everyone that a new game exists + template.convertAndSend("/topic/games", Collections.singletonList(lobby)); + return lobby; } @MessageMapping("/lobby/join") -- cgit