本文整理汇总了Java中org.springframework.messaging.simp.annotation.SubscribeMapping类的典型用法代码示例。如果您正苦于以下问题:Java SubscribeMapping类的具体用法?Java SubscribeMapping怎么用?Java SubscribeMapping使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SubscribeMapping类属于org.springframework.messaging.simp.annotation包,在下文中一共展示了SubscribeMapping类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendActivity
import org.springframework.messaging.simp.annotation.SubscribeMapping; //导入依赖的package包/类
@SubscribeMapping("/topic/activity")
@SendTo("/topic/tracker")
public ActivityDTO sendActivity(@Payload ActivityDTO activityDTO, StompHeaderAccessor stompHeaderAccessor, Principal principal) {
activityDTO.setUserLogin(SecurityUtils.getCurrentUserLogin());
activityDTO.setUserLogin(principal.getName());
activityDTO.setSessionId(stompHeaderAccessor.getSessionId());
activityDTO.setIpAddress(stompHeaderAccessor.getSessionAttributes().get(IP_ADDRESS).toString());
Instant instant = Instant.ofEpochMilli(Calendar.getInstance().getTimeInMillis());
activityDTO.setTime(dateTimeFormatter.format(ZonedDateTime.ofInstant(instant, ZoneOffset.systemDefault())));
log.debug("Sending user tracking data {}", activityDTO);
return activityDTO;
}
示例2: onSubscribe
import org.springframework.messaging.simp.annotation.SubscribeMapping; //导入依赖的package包/类
@SubscribeMapping("/queue/output")
public GameOutput onSubscribe(Principal principal,
@Header("breadcrumb") String breadcrumb,
@Header("simpSessionId") String simpSessionId) {
Session session = getSessionFromPrincipal(principal);
Map<String, String> sessionMap = session.getAttribute(breadcrumb);
Entity entity = entityRepository.findOne(sessionMap.get("entity"));
entity.setStompUsername(principal.getName());
entity.setStompSessionId(simpSessionId);
entity = entityRepository.save(entity);
GameOutput output = new GameOutput();
output.append("[black] ___ _ __ __ _ _ ___ ".replace(" ", " "));
output.append("[dwhite] | __|_ __ ___ _ _ __ _ ___ _ _| |_| \\/ | | | | \\ ".replace(" ", " "));
output.append("[dwhite] | _|| ' \\/ -_) '_/ _` / -_) ' \\ _| |\\/| | |_| | |) |".replace(" ", " "));
output.append("[white] |___|_|_|_\\___|_| \\__, \\___|_||_\\__|_| |_|\\___/|___/ ".replace(" ", " "));
output.append("[white] |___/ ".replace(" ", " "));
output.append("[white]Copyright © 2016-2017 Peter Keeler.");
output.append("[dwhite]EmergentMUD is licensed under the <a class=\"green\" target=\"_blank\" " +
"href=\"http://www.gnu.org/licenses/agpl-3.0.en.html\">GNU Affero General Public License</a>.");
output.append("[dwhite]EmergentMUD offers no warranties or guarantees. Play at your own risk.");
output.append("[red]EmergentMUD is in early stages of development. Reboots and database wipes may occur without warning!");
output.append("[dwhite]EmergentMUD is <a class=\"green\" target=\"_blank\" " +
"href=\"https://github.com/scionaltera/emergentmud\">free, open source software</a> that " +
"[white]you [dwhite]can contribute to, modify and distribute as you wish.");
output.append("[dwhite]EmergentMUD server status:");
output.append("[dwhite] Version: [white]v" + applicationVersion);
output.append("[dwhite] Up since: [white]" + new DateTime(applicationBootDate));
output.append(String.format("[yellow]Welcome to the world, %s!", entity.getName()));
output.append("");
Command command = (Command)applicationContext.getBean("lookCommand");
command.execute(output, entity, "look", new String[0], "");
promptBuilder.appendPrompt(output);
return output;
}
示例3: sendActivity
import org.springframework.messaging.simp.annotation.SubscribeMapping; //导入依赖的package包/类
@SubscribeMapping("/topic/activity")
@SendTo("/topic/tracker")
public ActivityDTO sendActivity(@Payload ActivityDTO activityDTO, StompHeaderAccessor stompHeaderAccessor, Principal principal) {
activityDTO.setUserLogin(principal.getName());
activityDTO.setSessionId(stompHeaderAccessor.getSessionId());
activityDTO.setIpAddress(stompHeaderAccessor.getSessionAttributes().get(IP_ADDRESS).toString());
activityDTO.setTime(Instant.now());
log.debug("Sending user tracking data {}", activityDTO);
return activityDTO;
}
示例4: subscribeEventDestinationVariable
import org.springframework.messaging.simp.annotation.SubscribeMapping; //导入依赖的package包/类
@SubscribeMapping("/sub/{foo}/{name}")
public void subscribeEventDestinationVariable(@DestinationVariable("foo") String param1,
@DestinationVariable("name") String param2) {
this.method = "subscribeEventDestinationVariable";
this.arguments.put("foo", param1);
this.arguments.put("name", param2);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:SimpAnnotationMethodMessageHandlerTests.java
示例5: getJsonView
import org.springframework.messaging.simp.annotation.SubscribeMapping; //导入依赖的package包/类
@SubscribeMapping("/jsonview") // not needed for the tests but here for completeness
@JsonView(MyJacksonView1.class)
public JacksonViewBean getJsonView() {
JacksonViewBean payload = new JacksonViewBean();
payload.setWithView1("with");
payload.setWithView2("with");
payload.setWithoutView("without");
return payload;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:SubscriptionMethodReturnValueHandlerTests.java
示例6: sendActivity
import org.springframework.messaging.simp.annotation.SubscribeMapping; //导入依赖的package包/类
@SubscribeMapping("/topic/activity")
@SendTo("/topic/tracker")
public ActivityDTO sendActivity(@Payload ActivityDTO activityDTO, StompHeaderAccessor stompHeaderAccessor, Principal principal) {
activityDTO.setUserLogin(SecurityUtils.getCurrentLogin());
activityDTO.setUserLogin(principal.getName());
activityDTO.setSessionId(stompHeaderAccessor.getSessionId());
activityDTO.setIpAddress(stompHeaderAccessor.getSessionAttributes().get(IP_ADDRESS).toString());
activityDTO.setTime(dateTimeFormatter.print(Calendar.getInstance().getTimeInMillis()));
log.debug("Sending user tracking data {}", activityDTO);
return activityDTO;
}
示例7: subscriptionHandler
import org.springframework.messaging.simp.annotation.SubscribeMapping; //导入依赖的package包/类
@RolesAllowed("ROLE_ADMIN")
@SubscribeMapping("/logs")
public void subscriptionHandler() {
if (configurationMediator.isClusterMode()) {
clusterEventPublisher.logWatcherStarted();
}
logsWatcherService.start();
logsWatcherService.sendLatestLogs();
}
示例8: sendActivity
import org.springframework.messaging.simp.annotation.SubscribeMapping; //导入依赖的package包/类
@SubscribeMapping("/topic/activity")
@SendTo("/topic/tracker")
public ActivityDTO sendActivity(@Payload ActivityDTO activityDTO, StompHeaderAccessor stompHeaderAccessor, Principal principal) {
activityDTO.setUserLogin(SecurityUtil.getCurrentUserLogin());
activityDTO.setUserLogin(principal.getName());
activityDTO.setSessionId(stompHeaderAccessor.getSessionId());
activityDTO.setIpAddress(stompHeaderAccessor.getSessionAttributes().get(ApplicationConstants.IP_ADDRESS).toString());
Instant instant = Instant.ofEpochMilli(Calendar.getInstance().getTimeInMillis());
activityDTO.setTime(dateTimeFormatter.format(ZonedDateTime.ofInstant(instant, ZoneOffset.systemDefault())));
log.debug("Sending user tracking data {}", activityDTO);
return activityDTO;
}
示例9: changePlayerState
import org.springframework.messaging.simp.annotation.SubscribeMapping; //导入依赖的package包/类
@SubscribeMapping("/topic/player_commands")
@SendTo("/topic/player_events")
public PlayerSnapshotDTO changePlayerState(@Payload PlayerStateDTO stateDTO,
StompHeaderAccessor stompHeaderAccessor, Principal principal) {
return null;
}
示例10: getlistEmail
import org.springframework.messaging.simp.annotation.SubscribeMapping; //导入依赖的package包/类
@SubscribeMapping("/email/list")
public List<EmailEntity> getlistEmail() {
return emailService.findAllEmail();
}
示例11: getParticipants
import org.springframework.messaging.simp.annotation.SubscribeMapping; //导入依赖的package包/类
@SubscribeMapping("/participants/{id}")
public List<ParticipantState> getParticipants(@DestinationVariable String id){
return loadOnlineParticipants(id);
}
示例12: getConversations
import org.springframework.messaging.simp.annotation.SubscribeMapping; //导入依赖的package包/类
@SubscribeMapping("/conversations")
public List<Conversation> getConversations(){
PageRequest req = PageRequest.of(0, 30, Direction.DESC, "date");
return conversationRepository.findAll(req).getContent();
}
示例13: subscribeMessages
import org.springframework.messaging.simp.annotation.SubscribeMapping; //导入依赖的package包/类
@SubscribeMapping("/users")
public List<String> subscribeMessages() throws Exception {
return this.activeUserRepository.findAllActiveUsers();
}
示例14: supportsReturnType
import org.springframework.messaging.simp.annotation.SubscribeMapping; //导入依赖的package包/类
@Override
public boolean supportsReturnType(MethodParameter returnType) {
return (returnType.getMethodAnnotation(SubscribeMapping.class) != null &&
returnType.getMethodAnnotation(SendTo.class) == null &&
returnType.getMethodAnnotation(SendToUser.class) == null);
}
示例15: getData
import org.springframework.messaging.simp.annotation.SubscribeMapping; //导入依赖的package包/类
@SubscribeMapping("/data") // not needed for the tests but here for completeness
private String getData() {
return PAYLOAD;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:5,代码来源:SubscriptionMethodReturnValueHandlerTests.java