diff options
author | Joffrey BION <joffrey.bion@gmail.com> | 2017-01-22 12:44:31 +0100 |
---|---|---|
committer | Joffrey BION <joffrey.bion@gmail.com> | 2017-01-22 12:44:31 +0100 |
commit | 9db69f168af6622e989047221eb07022a0c2c4e7 (patch) | |
tree | 05a7ddb6fcf89d962cd6b522d3479ab0270de606 /backend/src/main | |
parent | Merge remote-tracking branch 'remotes/origin/feature/front' (diff) | |
download | seven-wonders-9db69f168af6622e989047221eb07022a0c2c4e7.tar.gz seven-wonders-9db69f168af6622e989047221eb07022a0c2c4e7.tar.bz2 seven-wonders-9db69f168af6622e989047221eb07022a0c2c4e7.zip |
Ans /user/queue/lobby/joined message on game creation
Diffstat (limited to 'backend/src/main')
-rw-r--r-- | backend/src/main/java/org/luxons/sevenwonders/controllers/LobbyController.java | 10 |
1 files 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<Lobby> 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") |