当前位置: 首页>>代码示例>>Java>>正文


Java DestinationVariable类代码示例

本文整理汇总了Java中org.springframework.messaging.handler.annotation.DestinationVariable的典型用法代码示例。如果您正苦于以下问题:Java DestinationVariable类的具体用法?Java DestinationVariable怎么用?Java DestinationVariable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DestinationVariable类属于org.springframework.messaging.handler.annotation包,在下文中一共展示了DestinationVariable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleMessages

import org.springframework.messaging.handler.annotation.DestinationVariable; //导入依赖的package包/类
/**
 * Receive and send messages via websockets.
 * <p>
 * Note: public and private chats work the same way. The permission handling is
 * done at the SUBSCRIBE event as part of the AuthenticationInterceptor.
 *
 * @param roomId   String
 * @param message  Message
 * @param traveler Traveler
 * @return Message
 * @throws Exception
 */
@MessageMapping("/chat/{roomId}")
public Message handleMessages(@DestinationVariable("roomId") String roomId, @Payload Message message, Traveler traveler) throws Exception {
	System.out.println("Message received for room: " + roomId);
	System.out.println("User: " + traveler.toString());

	// store message in database
	message.setAuthor(traveler);
	message.setChatRoomId(Integer.parseInt(roomId));
	int id = MessageRepository.getInstance().save(message);
	message.setId(id);

	return message;
}
 
开发者ID:trvlrch,项目名称:trvlr-backend,代码行数:26,代码来源:ChatController.java

示例2: mix

import org.springframework.messaging.handler.annotation.DestinationVariable; //导入依赖的package包/类
@WampCallListener(value = "messageMethod/{id}")
public String mix(String param1, CallMessage message, int param2,
		WampSession wampSession, @Headers Map<String, Object> headers,
		@Header(value = "WAMP_MESSAGE_TYPE") WampMessageType wampMessageType,
		float param3, @DestinationVariable("id") int id, String param4) {

	assertThat(param1).isEqualTo("param1");
	assertThat(message).isNotNull();
	assertThat(message.getDestination()).isEqualTo("messageMethod/23");
	assertThat(param2).isEqualTo(2);
	assertThat(wampSession).isNotNull();
	assertThat(headers).hasSize(5);
	assertThat(wampMessageType).isEqualTo(WampMessageType.CALL);
	assertThat(param3).isEqualTo(3.3f);
	assertThat(id).isEqualTo(23);
	assertThat(param4).isEqualTo("param4");

	return "mix";
}
 
开发者ID:ralscha,项目名称:wampspring,代码行数:20,代码来源:CallParameterTestService.java

示例3: submissionSyntaxChecker

import org.springframework.messaging.handler.annotation.DestinationVariable; //导入依赖的package包/类
@MessageMapping("/javaparser/{taskInstanceId}")
public List<SyntaxError> submissionSyntaxChecker(
        @DestinationVariable Long taskInstanceId, String submissionCode) {
  logger.debug("Javaparser received message");

  return JavaSyntaxChecker
      .getSyntaxErrors(submissionCode)
      .orElse(new ArrayList<>());
}
 
开发者ID:tdd-pingis,项目名称:tdd-pingpong,代码行数:10,代码来源:SyntaxCheckController.java

示例4: rateTask

import org.springframework.messaging.handler.annotation.DestinationVariable; //导入依赖的package包/类
@MessageMapping("/rate/{taskInstanceId}")
public String rateTask(@DestinationVariable Long taskInstanceId, Integer rating) {
  logger.debug("Rating task");

  boolean rated = gameplayService
      .rate(rating, taskInstanceId);

  if (!rated) {
    logger.debug("Rating failed!");
    return "FAILED";
  }

  logger.debug("Rating ok!");
  return "OK";
}
 
开发者ID:tdd-pingis,项目名称:tdd-pingpong,代码行数:16,代码来源:TaskController.java

示例5: newConsumer

import org.springframework.messaging.handler.annotation.DestinationVariable; //导入依赖的package包/类
/**
 * Serves websocket requests, requesting to start a stream on the given view.
 */
@MessageMapping("/consume/{viewId}")
@Transactional
public String newConsumer(
    @DestinationVariable final Long viewId,
    final ConsumeRequest consumeRequest,
    final SimpMessageHeaderAccessor headerAccessor) {

    // Retrieve view
    final View view = viewRepository.findOne(viewId);
    if (view == null) {
        return "{success: false}";
    }

    // Build a session identifier
    final long userId = getLoggedInUserId(headerAccessor);
    final String sessionId = headerAccessor.getSessionId();
    final SessionIdentifier sessionIdentifier = new SessionIdentifier(userId, sessionId);

    // Override settings
    final ViewCustomizer viewCustomizer = new ViewCustomizer(view, consumeRequest);
    viewCustomizer.overrideViewSettings();
    final List<FilterDefinition> configuredFilters = viewCustomizer.getFilterDefinitions();

    // Configure where to start from
    final StartingPosition startingPosition = viewCustomizer.getStartingPosition();

    webSocketConsumersManager.addNewConsumer(view, configuredFilters, startingPosition, sessionIdentifier);
    return "{success: true}";
}
 
开发者ID:SourceLabOrg,项目名称:kafka-webview,代码行数:33,代码来源:StreamController.java

示例6: pauseConsumer

import org.springframework.messaging.handler.annotation.DestinationVariable; //导入依赖的package包/类
/**
 * Serves web socket requests, requesting to pause a consumer.
 */
@MessageMapping("/pause/{viewId}")
@Transactional
public String pauseConsumer(
    @DestinationVariable final Long viewId,
    final SimpMessageHeaderAccessor headerAccessor) {

    // Request a pause
    final long userId = getLoggedInUserId(headerAccessor);
    final String sessionId = headerAccessor.getSessionId();
    webSocketConsumersManager.pauseConsumer(viewId, new SessionIdentifier(userId, sessionId));
    return "{success: true}";
}
 
开发者ID:SourceLabOrg,项目名称:kafka-webview,代码行数:16,代码来源:StreamController.java

示例7: resumeConsumer

import org.springframework.messaging.handler.annotation.DestinationVariable; //导入依赖的package包/类
/**
 * Serves web socket requests, requesting to resume a consumer.
 */
@MessageMapping("/resume/{viewId}")
@Transactional
public String resumeConsumer(
    @DestinationVariable final Long viewId,
    final SimpMessageHeaderAccessor headerAccessor) {

    // Request Resume
    final long userId = getLoggedInUserId(headerAccessor);
    final String sessionId = headerAccessor.getSessionId();
    webSocketConsumersManager.resumeConsumer(viewId, new SessionIdentifier(userId, sessionId));
    return "{success: true}";
}
 
开发者ID:SourceLabOrg,项目名称:kafka-webview,代码行数:16,代码来源:StreamController.java

示例8: createMesage

import org.springframework.messaging.handler.annotation.DestinationVariable; //导入依赖的package包/类
@MessageMapping("/chat/{conversationId}")
@SendTo("/topic/chat/{conversationId}")
public ConversationMessage createMesage(
        @Payload CreateMessage message,
        @DestinationVariable String conversationId) {

    log.info("handleMessage {}", message);
    
    
    ConversationMessage conversationMessage = conversationService.create( message );
    if(conversationMessage.isUserMessage()){
        publisher.publishEvent(new UserMessageCreatedEvent(conversationMessage));
    }
    return conversationMessage;
}
 
开发者ID:peterjurkovic,项目名称:travel-agency,代码行数:16,代码来源:ConversationController.java

示例9: send

import org.springframework.messaging.handler.annotation.DestinationVariable; //导入依赖的package包/类
@MessageMapping("/chat/{topic}")
   @SendTo("/topic/messages")
   public OutputMessage send(@DestinationVariable("topic") String topic,
		      Message message) throws Exception
   {
return new OutputMessage(message.getFrom(), message.getText(), topic);
   }
 
开发者ID:jaysridhar,项目名称:spring-websocket-server,代码行数:8,代码来源:ChatController.java

示例10: messageMappingDestinationVariable

import org.springframework.messaging.handler.annotation.DestinationVariable; //导入依赖的package包/类
@MessageMapping("/message/{foo}/{name}")
public void messageMappingDestinationVariable(@DestinationVariable("foo") String param1,
		@DestinationVariable("name") String param2) {
	this.method = "messageMappingDestinationVariable";
	this.arguments.put("foo", param1);
	this.arguments.put("name", param2);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:SimpAnnotationMethodMessageHandlerTests.java

示例11: subscribeEventDestinationVariable

import org.springframework.messaging.handler.annotation.DestinationVariable; //导入依赖的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

示例12: sendContent

import org.springframework.messaging.handler.annotation.DestinationVariable; //导入依赖的package包/类
@MessageMapping("/queue/CSM_QUEUE_{queueId}")
  @SendTo("/queue/CSM_QUEUE_{queueId}")
  public List<StockProduct> sendContent(@Payload List<String> tickers, @DestinationVariable("queueId") String queueId) throws Exception {
  	String username = extractUserFromQueueId(queueId);
  	if(!getPrincipal().getUsername().equals(username)){
  		throw new IllegalAccessError("/queue/CSM_QUEUE_"+queueId);
  	}
return stockProductService.gather(username, tickers.toArray(new String[tickers.size()]));
  }
 
开发者ID:alex-bretet,项目名称:cloudstreetmarket.com,代码行数:10,代码来源:StockProductWSController.java

示例13: atualizaRetrospectiva

import org.springframework.messaging.handler.annotation.DestinationVariable; //导入依赖的package包/类
@MessageMapping("/retrospectiva/asndjkahsdjhds/{retrospectivaId}/{nomeUsuario}")
@SendTo("/message/retrospectiva/asndjkahsdjhds/{retrospectivaId}")
public ConteudoJson atualizaRetrospectiva(ConteudoJson conteudo, @DestinationVariable("retrospectivaId") Integer retrospectivaId, @DestinationVariable("nomeUsuario") String nomeUsuario) {
	Retrospectiva retrospectiva = retrospectivaDao.loadWebSocket(retrospectivaId);
	if(retrospectiva.isPublica() || (!nomeUsuario.isEmpty() && retrospectiva.isUsuarioAutorizado(usuarioDao.buscaPorNome(nomeUsuario)))) {
		atualizaRetrospectiva.atualiza(retrospectiva, conteudo);
		return conteudo;
	} else {
		return null;
	}
}
 
开发者ID:mxball,项目名称:suricato,代码行数:12,代码来源:RetrospectivaController.java

示例14: handle

import org.springframework.messaging.handler.annotation.DestinationVariable; //导入依赖的package包/类
@MessageMapping("/queue/channel/{channelPrivateId}")
public void handle(Message message, @DestinationVariable("channelPrivateId") String channelPrivateId, SimpMessageHeaderAccessor headerAccessor) throws IOException {

    String sessionId = (String) headerAccessor.getSessionAttributes().get(HTTP_SESSION_ID_ATTR_NAME);

    Channel channel = channelsManager.findByPrivateId(channelPrivateId).orElse(null);

    //Find Channel
    if (channel != null) {
        Map map = objectMapper.readValue((byte[]) message.getPayload(), Map.class);

        //Get target
        String toPublicId = (String) map.get("toPublicId");
        //Check if target is registered on the channel
        if (channel.findUserByPublicId(toPublicId).isPresent()) {

            usersManager.findUserBySessionId(sessionId).ifPresent(sender -> {
                Map newMsg = builder()
                        .put("channel", channel)
                        .put("author", sender.getName())
                        .put("message", map.get("message"))
                        .put("date", System.currentTimeMillis()).build();

                usersManager.findUserByPublicId((String) map.get("toPublicId")).ifPresent(u -> {
                    try {
                        this.messagingTemplate.convertAndSend("/queue/" + u.getPrivateId() + "/message", objectMapper.writeValueAsString(newMsg));
                    } catch (JsonProcessingException e) {
                        e.printStackTrace();
                    }
                });
            });
        }
    }
}
 
开发者ID:nithril,项目名称:whisper,代码行数:35,代码来源:ChannelController.java

示例15: subscribe

import org.springframework.messaging.handler.annotation.DestinationVariable; //导入依赖的package包/类
@WampSubscribeListener("/topic/{id}")
public void subscribe(SubscribeMessage subscribeMessage,
		@DestinationVariable("id") Integer clientId) {
	this.eventMessenger.sendToDirect("/topic", "join:" + clientId,
			this.wsToId.keySet());
	this.eventMessenger.sendTo("/topic", "IGNORED join:" + clientId,
			this.wsToId.keySet());

	this.wsToId.put(subscribeMessage.getWebSocketSessionId(), clientId);
}
 
开发者ID:ralscha,项目名称:wampspring,代码行数:11,代码来源:DirectService.java


注:本文中的org.springframework.messaging.handler.annotation.DestinationVariable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。