Search in sources :

Example 1 with MessageMapping

use of org.springframework.messaging.handler.annotation.MessageMapping in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.

the class MessageHandler method broadcasting.

@MessageMapping("/ready/{roomId}")
@SendTo("/from/ready/{roomId}")
public ReadySignal broadcasting(ReadySignal ready, @DestinationVariable long roomId) throws Exception {
    log.debug("ReadySignal arrived: /ready/{}, ready: {}", roomId, ready);
    Room room = lobby.getRoom(roomId);
    room.findByNickname(ready.getUserName()).toggleReady();
    if (room.isAllReady()) {
        ready.setStartTimer(true);
        room.createGameManager();
    }
    return ready;
}
Also used : Room(com.mapia.domain.Room) SendTo(org.springframework.messaging.handler.annotation.SendTo) MessageMapping(org.springframework.messaging.handler.annotation.MessageMapping)

Example 2 with MessageMapping

use of org.springframework.messaging.handler.annotation.MessageMapping in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.

the class MessageHandler method broadcasting.

@MessageMapping("/access/{roomId}")
@SendTo("/from/access/{roomId}")
public ClientAccess broadcasting(ClientAccess access, @DestinationVariable long roomId) throws Exception {
    log.debug("ClientAccess arrived: /access/{}, access: {}", roomId, access);
    Room room = lobby.getRoom(roomId);
    access.setUsers(room.getUsers());
    return access;
}
Also used : Room(com.mapia.domain.Room) SendTo(org.springframework.messaging.handler.annotation.SendTo) MessageMapping(org.springframework.messaging.handler.annotation.MessageMapping)

Example 3 with MessageMapping

use of org.springframework.messaging.handler.annotation.MessageMapping in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.

the class MessageHandler method broadcasting.

@MessageMapping("/gameStart/{roomId}/{userName}")
@SendTo("/from/gameStart/{roomId}/{userName}")
public String broadcasting(GameStart gameStart, @DestinationVariable long roomId, @DestinationVariable String userName) throws Exception {
    log.debug("GameStart arrived: /gameStart/{}/{}, gameStart: {}", roomId, userName, gameStart);
    Room gameRoom = lobby.getRoom(roomId);
    gameRoom.getUsers().forEach(user -> user.gameStart());
    return gameRoom.getUserRoleNameInGame(userName);
}
Also used : Room(com.mapia.domain.Room) SendTo(org.springframework.messaging.handler.annotation.SendTo) MessageMapping(org.springframework.messaging.handler.annotation.MessageMapping)

Example 4 with MessageMapping

use of org.springframework.messaging.handler.annotation.MessageMapping in project spring-framework by spring-projects.

the class RSocketMessageHandler method getCondition.

@Override
@Nullable
protected CompositeMessageCondition getCondition(AnnotatedElement element) {
    MessageMapping ann1 = AnnotatedElementUtils.findMergedAnnotation(element, MessageMapping.class);
    if (ann1 != null && ann1.value().length > 0) {
        return new CompositeMessageCondition(RSocketFrameTypeMessageCondition.EMPTY_CONDITION, new DestinationPatternsMessageCondition(processDestinations(ann1.value()), obtainRouteMatcher()));
    }
    ConnectMapping ann2 = AnnotatedElementUtils.findMergedAnnotation(element, ConnectMapping.class);
    if (ann2 != null) {
        String[] patterns = processDestinations(ann2.value());
        return new CompositeMessageCondition(RSocketFrameTypeMessageCondition.CONNECT_CONDITION, new DestinationPatternsMessageCondition(patterns, obtainRouteMatcher()));
    }
    return null;
}
Also used : CompositeMessageCondition(org.springframework.messaging.handler.CompositeMessageCondition) DestinationPatternsMessageCondition(org.springframework.messaging.handler.DestinationPatternsMessageCondition) ConnectMapping(org.springframework.messaging.rsocket.annotation.ConnectMapping) MessageMapping(org.springframework.messaging.handler.annotation.MessageMapping) Nullable(org.springframework.lang.Nullable)

Example 5 with MessageMapping

use of org.springframework.messaging.handler.annotation.MessageMapping in project spring-framework by spring-projects.

the class MessageMappingMessageHandler method getCondition.

/**
 * Determine the mapping condition for the given annotated element.
 * @param element the element to check
 * @return the condition, or {@code null}
 */
@Nullable
protected CompositeMessageCondition getCondition(AnnotatedElement element) {
    MessageMapping ann = AnnotatedElementUtils.findMergedAnnotation(element, MessageMapping.class);
    if (ann == null || ann.value().length == 0) {
        return null;
    }
    String[] patterns = processDestinations(ann.value());
    return new CompositeMessageCondition(new DestinationPatternsMessageCondition(patterns, obtainRouteMatcher()));
}
Also used : CompositeMessageCondition(org.springframework.messaging.handler.CompositeMessageCondition) DestinationPatternsMessageCondition(org.springframework.messaging.handler.DestinationPatternsMessageCondition) MessageMapping(org.springframework.messaging.handler.annotation.MessageMapping) Nullable(org.springframework.lang.Nullable)

Aggregations

MessageMapping (org.springframework.messaging.handler.annotation.MessageMapping)10 SendTo (org.springframework.messaging.handler.annotation.SendTo)6 Room (com.mapia.domain.Room)4 ResponseMessage (com.hry.spring.mvc.websocket.model.ResponseMessage)3 Nullable (org.springframework.lang.Nullable)3 CompositeMessageCondition (org.springframework.messaging.handler.CompositeMessageCondition)2 DestinationPatternsMessageCondition (org.springframework.messaging.handler.DestinationPatternsMessageCondition)2 ConnectMapping (org.springframework.messaging.rsocket.annotation.ConnectMapping)1 SimpMessageMappingInfo (org.springframework.messaging.simp.SimpMessageMappingInfo)1 SendToUser (org.springframework.messaging.simp.annotation.SendToUser)1 SubscribeMapping (org.springframework.messaging.simp.annotation.SubscribeMapping)1