org.springframework.messaging.handler.annotation.DestinationVariable Java Examples

The following examples show how to use org.springframework.messaging.handler.annotation.DestinationVariable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MatchService.java    From spring4ws-demos with Apache License 2.0 5 votes vote down vote up
@MessageMapping("/tennis/bet/{clientId}/{matchId}")
public void bet(String winner, @DestinationVariable("clientId") String clientId,
		@DestinationVariable("matchId") String matchId) {
	Map<String, String> clientBets = matchClientBets.get(matchId);
	clientBets.put(clientId, winner);

	System.out.println(clientId);
	System.out.println(winner);
	System.out.println(matchId);
}
 
Example #2
Source File: SimpAnnotationMethodMessageHandlerTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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);
}
 
Example #3
Source File: SimpAnnotationMethodMessageHandlerTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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);
}
 
Example #4
Source File: SimpAnnotationMethodMessageHandlerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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);
}
 
Example #5
Source File: SimpAnnotationMethodMessageHandlerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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);
}
 
Example #6
Source File: StreamController.java    From kafka-webview with MIT License 5 votes vote down vote up
/**
 * Serves websocket requests, requesting to start a stream on the given view.
 */
@MessageMapping("/consume/{viewId}")
@Transactional(readOnly = true)
public String newConsumer(
    @DestinationVariable final Long viewId,
    final ConsumeRequest consumeRequest,
    final SimpMessageHeaderAccessor headerAccessor) {

    // Retrieve view
    final Optional<View> viewOptional = viewRepository.findById(viewId);
    if (!viewOptional.isPresent()) {
        return "{success: false}";
    }
    final View view = viewOptional.get();

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

    // Override settings
    // TODO View gets flushed and changes are persisted.
    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}";
}
 
Example #7
Source File: StreamController.java    From kafka-webview with MIT License 5 votes vote down vote up
/**
 * Serves web socket requests, requesting to pause a consumer.
 */
@MessageMapping("/pause/{viewId}")
@Transactional(readOnly = true)
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, SessionIdentifier.newStreamIdentifier(userId, sessionId));
    return "{success: true}";
}
 
Example #8
Source File: StreamController.java    From kafka-webview with MIT License 5 votes vote down vote up
/**
 * Serves web socket requests, requesting to resume a consumer.
 */
@MessageMapping("/resume/{viewId}")
@Transactional(readOnly = true)
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, SessionIdentifier.newStreamIdentifier(userId, sessionId));
    return "{success: true}";
}
 
Example #9
Source File: TtyController.java    From flow-platform-x with Apache License 2.0 5 votes vote down vote up
@MessageMapping("/tty/{jobId}/open")
public void open(@DestinationVariable String jobId, MessageHeaders headers) {
    TtyCmd.In in = new TtyCmd.In()
            .setId(jobId)
            .setAction(TtyCmd.Action.OPEN);

    validate(in, headers);
    ttyService.execute(in);
}
 
Example #10
Source File: TtyController.java    From flow-platform-x with Apache License 2.0 5 votes vote down vote up
@MessageMapping("/tty/{jobId}/shell")
public void shell(@DestinationVariable String jobId, @Payload String script, MessageHeaders headers) {
    TtyCmd.In in = new TtyCmd.In()
            .setId(jobId)
            .setAction(TtyCmd.Action.SHELL)
            .setInput(script);

    validate(in, headers);
    ttyService.execute(in);
}
 
Example #11
Source File: TtyController.java    From flow-platform-x with Apache License 2.0 5 votes vote down vote up
@MessageMapping("/tty/{jobId}/close")
public void close(@DestinationVariable String jobId, MessageHeaders headers) {
    TtyCmd.In in = new TtyCmd.In()
            .setId(jobId)
            .setAction(TtyCmd.Action.CLOSE);

    validate(in, headers);
    ttyService.execute(in);
}
 
Example #12
Source File: ChatController.java    From spring-websocket-server with MIT License 5 votes vote down vote up
@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);
   }
 
Example #13
Source File: SimpAnnotationMethodMessageHandlerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #14
Source File: SimpAnnotationMethodMessageHandlerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #15
Source File: StockProductWSController.java    From cloudstreetmarket.com with GNU General Public License v3.0 5 votes vote down vote up
@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()]));
  }
 
Example #16
Source File: PlayQueueWSController.java    From airsonic-advanced with GNU General Public License v3.0 4 votes vote down vote up
@MessageMapping("/reloadsearch")
public void reloadSearchCriteria(@DestinationVariable int playerId, SimpMessageHeaderAccessor headers) throws Exception {
    Player player = getPlayer(playerId, headers);
    playQueueService.reloadSearchCriteria(player, headers.getSessionId());
}
 
Example #17
Source File: PlayQueueWSController.java    From airsonic-advanced with GNU General Public License v3.0 4 votes vote down vote up
@MessageMapping("/play/podcastchannel")
public void playPodcastChannel(@DestinationVariable int playerId, PlayQueueRequest req, SimpMessageHeaderAccessor headers) throws Exception {
    Player player = getPlayer(playerId, headers);
    playQueueService.playPodcastChannel(player, req.getId(), headers.getSessionId());
}
 
Example #18
Source File: PlayQueueWSController.java    From airsonic-advanced with GNU General Public License v3.0 4 votes vote down vote up
@MessageMapping("/play/podcastepisode")
public void playPodcastEpisode(@DestinationVariable int playerId, PlayQueueRequest req, SimpMessageHeaderAccessor headers) throws Exception {
    Player player = getPlayer(playerId, headers);
    playQueueService.playPodcastEpisode(player, req.getId(), headers.getSessionId());
}
 
Example #19
Source File: DestinationVariableMethodArgumentResolver.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public boolean supportsParameter(MethodParameter parameter) {
	return parameter.hasParameterAnnotation(DestinationVariable.class);
}
 
Example #20
Source File: WebSocketController.java    From torrssen2 with MIT License 4 votes vote down vote up
@MessageMapping("/rate/{sid}")
public DownloadList downloadRate(@DestinationVariable String sid) throws Exception {
    return downloadService.getInfo(Long.valueOf(sid));
}
 
Example #21
Source File: PlayQueueWSController.java    From airsonic-advanced with GNU General Public License v3.0 4 votes vote down vote up
@MessageMapping("/play/starred")
public void playStarred(@DestinationVariable int playerId, SimpMessageHeaderAccessor headers) throws Exception {
    Player player = getPlayer(playerId, headers);
    playQueueService.playStarred(player, headers.getSessionId());
}
 
Example #22
Source File: DestinationVariableMethodArgumentResolver.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
	DestinationVariable annotation = parameter.getParameterAnnotation(DestinationVariable.class);
	Assert.state(annotation != null, "No DestinationVariable annotation");
	return new DestinationVariableNamedValueInfo(annotation);
}
 
Example #23
Source File: DestinationVariableMethodArgumentResolverTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@SuppressWarnings("unused")
private void handleMessage(
		@DestinationVariable String foo,
		@DestinationVariable(value = "name") String param1,
		String param3) {
}
 
Example #24
Source File: PlayQueueWSController.java    From airsonic-advanced with GNU General Public License v3.0 4 votes vote down vote up
@MessageMapping("/play/topsongs")
public void playTopSong(@DestinationVariable int playerId, PlayQueueRequest req, SimpMessageHeaderAccessor headers) throws Exception {
    Player player = getPlayer(playerId, headers);
    playQueueService.playTopSong(player, req.getId(), req.getIndex(), headers.getSessionId());
}
 
Example #25
Source File: PlayQueueWSController.java    From airsonic-advanced with GNU General Public License v3.0 4 votes vote down vote up
@MessageMapping("/play/playlist")
public void playPlaylist(@DestinationVariable int playerId, PlayQueueRequest req, SimpMessageHeaderAccessor headers) throws Exception {
    Player player = getPlayer(playerId, headers);
    playQueueService.playPlaylist(player, req.getId(), req.getIndex(), headers.getSessionId());
}
 
Example #26
Source File: PlayQueueWSController.java    From airsonic-advanced with GNU General Public License v3.0 4 votes vote down vote up
@MessageMapping("/play/radio")
public void playInternetRadio(@DestinationVariable int playerId, PlayQueueRequest req, SimpMessageHeaderAccessor headers) throws Exception {
    Player player = getPlayer(playerId, headers);
    playQueueService.playInternetRadio(player, req.getId(), req.getIndex(), headers.getSessionId());
}
 
Example #27
Source File: PlayQueueWSController.java    From airsonic-advanced with GNU General Public License v3.0 4 votes vote down vote up
@MessageMapping("/play/mediafile")
public void playMediaFile(@DestinationVariable int playerId, PlayQueueRequest req, SimpMessageHeaderAccessor headers) throws Exception {
    Player player = getPlayer(playerId, headers);
    playQueueService.playMediaFile(player, req.getId(), headers.getSessionId());
}
 
Example #28
Source File: PlayQueueWSController.java    From airsonic-advanced with GNU General Public License v3.0 4 votes vote down vote up
@MessageMapping("/play/saved")
public void loadSavedPlayQueue(@DestinationVariable int playerId, SimpMessageHeaderAccessor headers) throws Exception {
    Player player = getPlayer(playerId, headers);
    playQueueService.loadSavedPlayQueue(player, headers.getSessionId());
}
 
Example #29
Source File: PlayQueueWSController.java    From airsonic-advanced with GNU General Public License v3.0 4 votes vote down vote up
@MessageMapping("/save")
@SendToUser
public int savePlayQueue(@DestinationVariable int playerId, PlayQueueRequest req, SimpMessageHeaderAccessor headers) throws Exception {
    Player player = getPlayer(playerId, headers);
    return playQueueService.savePlayQueue(player, req.getIndex(), req.getOffset());
}
 
Example #30
Source File: SimpAnnotationMethodMessageHandlerTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@MessageMapping("/binding/id/{id}")
public void simpleBinding(@DestinationVariable("id") Long id) {
	this.method = "simpleBinding";
	this.arguments.put("id", id);
}