Here are the examples of the java api org.springframework.messaging.simp.SimpMessageHeaderAccessor taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
195 Examples
19
View Source File : StompSubProtocolHandler.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Nullable
private String getDisconnectReceipt(SimpMessageHeaderAccessor simpHeaders) {
String name = StompHeaderAccessor.DISCONNECT_MESSAGE_HEADER;
Message<?> message = (Message<?>) simpHeaders.getHeader(name);
if (message != null) {
StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.clreplaced);
if (accessor != null) {
return accessor.getReceipt();
}
}
return null;
}
19
View Source File : SimpleBrokerMessageHandlerTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
private boolean messageCaptured(String sessionId, String subscriptionId, String destination) {
for (Message<?> message : this.messageCaptor.getAllValues()) {
SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(message);
if (sessionId.equals(headers.getSessionId())) {
if (subscriptionId.equals(headers.getSubscriptionId())) {
if (destination.equals(headers.getDestination())) {
return true;
}
}
}
}
return false;
}
19
View Source File : SendToMethodReturnValueHandlerTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void sendToUser() throws Exception {
given(this.messageChannel.send(any(Message.clreplaced))).willReturn(true);
String sessionId = "sess1";
TestUser user = new TestUser();
Message<?> inputMessage = createMessage(sessionId, "sub1", null, null, user);
this.handler.handleReturnValue(PAYLOAD, this.sendToUserReturnType, inputMessage);
verify(this.messageChannel, times(2)).send(this.messageCaptor.capture());
SimpMessageHeaderAccessor accessor = getCapturedAccessor(0);
replacedertNull(accessor.getSessionId());
replacedertNull(accessor.getSubscriptionId());
replacedertEquals("/user/" + user.getName() + "/dest1", accessor.getDestination());
accessor = getCapturedAccessor(1);
replacedertNull(accessor.getSessionId());
replacedertNull(accessor.getSubscriptionId());
replacedertEquals("/user/" + user.getName() + "/dest2", accessor.getDestination());
}
19
View Source File : SendToMethodReturnValueHandlerTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void sendToDefaultDestinationWhenUsingDotPathSeparator() throws Exception {
given(this.messageChannel.send(any(Message.clreplaced))).willReturn(true);
Message<?> inputMessage = createMessage("sess1", "sub1", "/app/", "dest.foo.bar", null);
this.handler.handleReturnValue(PAYLOAD, this.sendToDefaultDestReturnType, inputMessage);
verify(this.messageChannel, times(1)).send(this.messageCaptor.capture());
SimpMessageHeaderAccessor accessor = getCapturedAccessor(0);
replacedertEquals("/topic/dest.foo.bar", accessor.getDestination());
}
19
View Source File : SendToMethodReturnValueHandlerTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void sendToAndSendToUser() throws Exception {
given(this.messageChannel.send(any(Message.clreplaced))).willReturn(true);
String sessionId = "sess1";
TestUser user = new TestUser();
Message<?> inputMessage = createMessage(sessionId, "sub1", null, null, user);
this.handler.handleReturnValue(PAYLOAD, this.sendToSendToUserReturnType, inputMessage);
verify(this.messageChannel, times(4)).send(this.messageCaptor.capture());
SimpMessageHeaderAccessor accessor = getCapturedAccessor(0);
replacedertNull(accessor.getSessionId());
replacedertNull(accessor.getSubscriptionId());
replacedertEquals("/user/" + user.getName() + "/dest1", accessor.getDestination());
accessor = getCapturedAccessor(1);
replacedertNull(accessor.getSessionId());
replacedertNull(accessor.getSubscriptionId());
replacedertEquals("/user/" + user.getName() + "/dest2", accessor.getDestination());
accessor = getCapturedAccessor(2);
replacedertEquals("sess1", accessor.getSessionId());
replacedertNull(accessor.getSubscriptionId());
replacedertEquals("/dest1", accessor.getDestination());
accessor = getCapturedAccessor(3);
replacedertEquals("sess1", accessor.getSessionId());
replacedertNull(accessor.getSubscriptionId());
replacedertEquals("/dest2", accessor.getDestination());
}
19
View Source File : SendToMethodReturnValueHandlerTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void sendToUserDefaultDestinationWhenUsingDotPathSeparator() throws Exception {
given(this.messageChannel.send(any(Message.clreplaced))).willReturn(true);
TestUser user = new TestUser();
Message<?> inputMessage = createMessage("sess1", "sub1", "/app/", "dest.foo.bar", user);
this.handler.handleReturnValue(PAYLOAD, this.sendToUserDefaultDestReturnType, inputMessage);
verify(this.messageChannel, times(1)).send(this.messageCaptor.capture());
SimpMessageHeaderAccessor accessor = getCapturedAccessor(0);
replacedertEquals("/user/" + user.getName() + "/queue/dest.foo.bar", accessor.getDestination());
}
19
View Source File : SendToMethodReturnValueHandlerTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void sendToUserDefaultDestination() throws Exception {
given(this.messageChannel.send(any(Message.clreplaced))).willReturn(true);
String sessionId = "sess1";
TestUser user = new TestUser();
Message<?> inputMessage = createMessage(sessionId, "sub1", "/app", "/dest", user);
this.handler.handleReturnValue(PAYLOAD, this.sendToUserDefaultDestReturnType, inputMessage);
verify(this.messageChannel, times(1)).send(this.messageCaptor.capture());
SimpMessageHeaderAccessor accessor = getCapturedAccessor(0);
replacedertNull(accessor.getSessionId());
replacedertNull(accessor.getSubscriptionId());
replacedertEquals("/user/" + user.getName() + "/queue/dest", accessor.getDestination());
}
19
View Source File : SendToMethodReturnValueHandlerTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void sendToUserWithUserNameProvider() throws Exception {
given(this.messageChannel.send(any(Message.clreplaced))).willReturn(true);
String sessionId = "sess1";
TestUser user = new UniqueUser();
Message<?> inputMessage = createMessage(sessionId, "sub1", null, null, user);
this.handler.handleReturnValue(PAYLOAD, this.sendToUserReturnType, inputMessage);
verify(this.messageChannel, times(2)).send(this.messageCaptor.capture());
SimpMessageHeaderAccessor accessor = getCapturedAccessor(0);
replacedertEquals("/user/Me myself and I/dest1", accessor.getDestination());
accessor = getCapturedAccessor(1);
replacedertEquals("/user/Me myself and I/dest2", accessor.getDestination());
}
19
View Source File : SendToMethodReturnValueHandlerTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void sendToUserSessionWithoutUserName() throws Exception {
given(this.messageChannel.send(any(Message.clreplaced))).willReturn(true);
String sessionId = "sess1";
Message<?> inputMessage = createMessage(sessionId, "sub1", null, null, null);
this.handler.handleReturnValue(PAYLOAD, this.sendToUserReturnType, inputMessage);
verify(this.messageChannel, times(2)).send(this.messageCaptor.capture());
SimpMessageHeaderAccessor accessor = getCapturedAccessor(0);
replacedertEquals("/user/sess1/dest1", accessor.getDestination());
replacedertEquals("sess1", accessor.getSessionId());
accessor = getCapturedAccessor(1);
replacedertEquals("/user/sess1/dest2", accessor.getDestination());
replacedertEquals("sess1", accessor.getSessionId());
}
19
View Source File : UserDestinationMessageHandler.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
private void initHeaders(SimpMessageHeaderAccessor headerAccessor) {
if (getHeaderInitializer() != null) {
getHeaderInitializer().initHeaders(headerAccessor);
}
}
19
View Source File : SimpleBrokerMessageHandler.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
private void initHeaders(SimpMessageHeaderAccessor accessor) {
if (getHeaderInitializer() != null) {
getHeaderInitializer().initHeaders(accessor);
}
}
19
View Source File : StreamController.java
License : MIT License
Project Creator : SourceLabOrg
License : MIT License
Project Creator : SourceLabOrg
/**
* 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}";
}
19
View Source File : StreamController.java
License : MIT License
Project Creator : SourceLabOrg
License : MIT License
Project Creator : SourceLabOrg
/**
* @return Currently logged in user Id.
*/
private long getLoggedInUserId(final SimpMessageHeaderAccessor headerAccessor) {
return getLoggedInUser(headerAccessor).getUserId();
}
19
View Source File : StreamController.java
License : MIT License
Project Creator : SourceLabOrg
License : MIT License
Project Creator : SourceLabOrg
/**
* @return Currently logged in user's details.
*/
private CustomUserDetails getLoggedInUser(final SimpMessageHeaderAccessor headerAccessor) {
// If we're using anonymous access
if (!appProperties.isUserAuthEnabled()) {
// Return default 'anonymous' user.
return AnonymousUserDetailsService.getDefaultAnonymousUser();
}
return (CustomUserDetails) ((Authentication) headerAccessor.getUser()).getPrincipal();
}
19
View Source File : SendToMethodReturnValueHandlerTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void sendToDefaultDestinationWhenUsingDotPathSeparator() throws Exception {
given(this.messageChannel.send(any(Message.clreplaced))).willReturn(true);
Message<?> inputMessage = createMessage("sess1", "sub1", "/app/", "dest.foo.bar", null);
this.handler.handleReturnValue(PAYLOAD, this.sendToDefaultDestReturnType, inputMessage);
verify(this.messageChannel, times(1)).send(this.messageCaptor.capture());
SimpMessageHeaderAccessor accessor = getCapturedAccessor(0);
replacedertThat(accessor.getDestination()).isEqualTo("/topic/dest.foo.bar");
}
19
View Source File : SendToMethodReturnValueHandlerTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void sendToAndSendToUser() throws Exception {
given(this.messageChannel.send(any(Message.clreplaced))).willReturn(true);
String sessionId = "sess1";
TestUser user = new TestUser();
Message<?> inputMessage = createMessage(sessionId, "sub1", null, null, user);
this.handler.handleReturnValue(PAYLOAD, this.sendToSendToUserReturnType, inputMessage);
verify(this.messageChannel, times(4)).send(this.messageCaptor.capture());
SimpMessageHeaderAccessor accessor = getCapturedAccessor(0);
replacedertThat(accessor.getSessionId()).isNull();
replacedertThat(accessor.getSubscriptionId()).isNull();
replacedertThat(accessor.getDestination()).isEqualTo(("/user/" + user.getName() + "/dest1"));
accessor = getCapturedAccessor(1);
replacedertThat(accessor.getSessionId()).isNull();
replacedertThat(accessor.getSubscriptionId()).isNull();
replacedertThat(accessor.getDestination()).isEqualTo(("/user/" + user.getName() + "/dest2"));
accessor = getCapturedAccessor(2);
replacedertThat(accessor.getSessionId()).isEqualTo("sess1");
replacedertThat(accessor.getSubscriptionId()).isNull();
replacedertThat(accessor.getDestination()).isEqualTo("/dest1");
accessor = getCapturedAccessor(3);
replacedertThat(accessor.getSessionId()).isEqualTo("sess1");
replacedertThat(accessor.getSubscriptionId()).isNull();
replacedertThat(accessor.getDestination()).isEqualTo("/dest2");
}
19
View Source File : SendToMethodReturnValueHandlerTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void sendToUserDefaultDestinationWhenUsingDotPathSeparator() throws Exception {
given(this.messageChannel.send(any(Message.clreplaced))).willReturn(true);
TestUser user = new TestUser();
Message<?> inputMessage = createMessage("sess1", "sub1", "/app/", "dest.foo.bar", user);
this.handler.handleReturnValue(PAYLOAD, this.sendToUserDefaultDestReturnType, inputMessage);
verify(this.messageChannel, times(1)).send(this.messageCaptor.capture());
SimpMessageHeaderAccessor accessor = getCapturedAccessor(0);
replacedertThat(accessor.getDestination()).isEqualTo(("/user/" + user.getName() + "/queue/dest.foo.bar"));
}
19
View Source File : SendToMethodReturnValueHandlerTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void sendToUserSessionWithoutUserName() throws Exception {
given(this.messageChannel.send(any(Message.clreplaced))).willReturn(true);
String sessionId = "sess1";
Message<?> inputMessage = createMessage(sessionId, "sub1", null, null, null);
this.handler.handleReturnValue(PAYLOAD, this.sendToUserReturnType, inputMessage);
verify(this.messageChannel, times(2)).send(this.messageCaptor.capture());
SimpMessageHeaderAccessor accessor = getCapturedAccessor(0);
replacedertThat(accessor.getDestination()).isEqualTo("/user/sess1/dest1");
replacedertThat(accessor.getSessionId()).isEqualTo("sess1");
accessor = getCapturedAccessor(1);
replacedertThat(accessor.getDestination()).isEqualTo("/user/sess1/dest2");
replacedertThat(accessor.getSessionId()).isEqualTo("sess1");
}
19
View Source File : SendToMethodReturnValueHandlerTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void sendToUserDefaultDestination() throws Exception {
given(this.messageChannel.send(any(Message.clreplaced))).willReturn(true);
String sessionId = "sess1";
TestUser user = new TestUser();
Message<?> inputMessage = createMessage(sessionId, "sub1", "/app", "/dest", user);
this.handler.handleReturnValue(PAYLOAD, this.sendToUserDefaultDestReturnType, inputMessage);
verify(this.messageChannel, times(1)).send(this.messageCaptor.capture());
SimpMessageHeaderAccessor accessor = getCapturedAccessor(0);
replacedertThat(accessor.getSessionId()).isNull();
replacedertThat(accessor.getSubscriptionId()).isNull();
replacedertThat(accessor.getDestination()).isEqualTo(("/user/" + user.getName() + "/queue/dest"));
}
19
View Source File : SendToMethodReturnValueHandlerTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void sendToUser() throws Exception {
given(this.messageChannel.send(any(Message.clreplaced))).willReturn(true);
String sessionId = "sess1";
TestUser user = new TestUser();
Message<?> inputMessage = createMessage(sessionId, "sub1", null, null, user);
this.handler.handleReturnValue(PAYLOAD, this.sendToUserReturnType, inputMessage);
verify(this.messageChannel, times(2)).send(this.messageCaptor.capture());
SimpMessageHeaderAccessor accessor = getCapturedAccessor(0);
replacedertThat(accessor.getSessionId()).isNull();
replacedertThat(accessor.getSubscriptionId()).isNull();
replacedertThat(accessor.getDestination()).isEqualTo(("/user/" + user.getName() + "/dest1"));
accessor = getCapturedAccessor(1);
replacedertThat(accessor.getSessionId()).isNull();
replacedertThat(accessor.getSubscriptionId()).isNull();
replacedertThat(accessor.getDestination()).isEqualTo(("/user/" + user.getName() + "/dest2"));
}
19
View Source File : SendToMethodReturnValueHandlerTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@Test
public void sendToUserWithUserNameProvider() throws Exception {
given(this.messageChannel.send(any(Message.clreplaced))).willReturn(true);
String sessionId = "sess1";
TestUser user = new UniqueUser();
Message<?> inputMessage = createMessage(sessionId, "sub1", null, null, user);
this.handler.handleReturnValue(PAYLOAD, this.sendToUserReturnType, inputMessage);
verify(this.messageChannel, times(2)).send(this.messageCaptor.capture());
SimpMessageHeaderAccessor accessor = getCapturedAccessor(0);
replacedertThat(accessor.getDestination()).isEqualTo("/user/Me myself and I/dest1");
accessor = getCapturedAccessor(1);
replacedertThat(accessor.getDestination()).isEqualTo("/user/Me myself and I/dest2");
}
19
View Source File : TurnController.java
License : GNU Affero General Public License v3.0
Project Creator : MatagTheGame
License : GNU Affero General Public License v3.0
Project Creator : MatagTheGame
@MessageMapping("/healthcheck")
public void healthcheck(SimpMessageHeaderAccessor headerAccessor) {
gameStatusUpdaterService.sendHealthcheck(headerAccessor.getSessionId());
}
19
View Source File : SimpleBrokerMessageHandlerTests.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
private boolean messageCaptured(String sessionId, String subcriptionId, String destination) {
for (Message<?> message : this.messageCaptor.getAllValues()) {
SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(message);
if (sessionId.equals(headers.getSessionId())) {
if (subcriptionId.equals(headers.getSubscriptionId())) {
if (destination.equals(headers.getDestination())) {
return true;
}
}
}
}
return false;
}
19
View Source File : SendToMethodReturnValueHandlerTests.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
@Test
public void sendToUserDefaultDestinationWhenUsingDotPathSeparator() throws Exception {
given(this.messageChannel.send(any(Message.clreplaced))).willReturn(true);
TestUser user = new TestUser();
Message<?> inputMessage = createInputMessage("sess1", "sub1", "/app/", "dest.foo.bar", user);
this.handler.handleReturnValue(PAYLOAD, this.sendToUserDefaultDestReturnType, inputMessage);
verify(this.messageChannel, times(1)).send(this.messageCaptor.capture());
SimpMessageHeaderAccessor accessor = getCapturedAccessor(0);
replacedertEquals("/user/" + user.getName() + "/queue/dest.foo.bar", accessor.getDestination());
}
19
View Source File : SendToMethodReturnValueHandlerTests.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
@Test
public void sendToUserDefaultDestination() throws Exception {
given(this.messageChannel.send(any(Message.clreplaced))).willReturn(true);
String sessionId = "sess1";
TestUser user = new TestUser();
Message<?> inputMessage = createInputMessage(sessionId, "sub1", "/app", "/dest", user);
this.handler.handleReturnValue(PAYLOAD, this.sendToUserDefaultDestReturnType, inputMessage);
verify(this.messageChannel, times(1)).send(this.messageCaptor.capture());
SimpMessageHeaderAccessor accessor = getCapturedAccessor(0);
replacedertNull(accessor.getSessionId());
replacedertNull(accessor.getSubscriptionId());
replacedertEquals("/user/" + user.getName() + "/queue/dest", accessor.getDestination());
}
19
View Source File : SendToMethodReturnValueHandlerTests.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
@Test
public void sendToUserWithUserNameProvider() throws Exception {
given(this.messageChannel.send(any(Message.clreplaced))).willReturn(true);
String sessionId = "sess1";
TestUser user = new UniqueUser();
Message<?> inputMessage = createInputMessage(sessionId, "sub1", null, null, user);
this.handler.handleReturnValue(PAYLOAD, this.sendToUserReturnType, inputMessage);
verify(this.messageChannel, times(2)).send(this.messageCaptor.capture());
SimpMessageHeaderAccessor accessor = getCapturedAccessor(0);
replacedertEquals("/user/Me myself and I/dest1", accessor.getDestination());
accessor = getCapturedAccessor(1);
replacedertEquals("/user/Me myself and I/dest2", accessor.getDestination());
}
19
View Source File : SendToMethodReturnValueHandlerTests.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
@Test
public void sendToUserSessionWithoutUserName() throws Exception {
given(this.messageChannel.send(any(Message.clreplaced))).willReturn(true);
String sessionId = "sess1";
Message<?> inputMessage = createInputMessage(sessionId, "sub1", null, null, null);
this.handler.handleReturnValue(PAYLOAD, this.sendToUserReturnType, inputMessage);
verify(this.messageChannel, times(2)).send(this.messageCaptor.capture());
SimpMessageHeaderAccessor accessor = getCapturedAccessor(0);
replacedertEquals("/user/sess1/dest1", accessor.getDestination());
replacedertEquals("sess1", accessor.getSessionId());
accessor = getCapturedAccessor(1);
replacedertEquals("/user/sess1/dest2", accessor.getDestination());
replacedertEquals("sess1", accessor.getSessionId());
}
19
View Source File : SendToMethodReturnValueHandlerTests.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
@Test
public void sendToUser() throws Exception {
given(this.messageChannel.send(any(Message.clreplaced))).willReturn(true);
String sessionId = "sess1";
TestUser user = new TestUser();
Message<?> inputMessage = createInputMessage(sessionId, "sub1", null, null, user);
this.handler.handleReturnValue(PAYLOAD, this.sendToUserReturnType, inputMessage);
verify(this.messageChannel, times(2)).send(this.messageCaptor.capture());
SimpMessageHeaderAccessor accessor = getCapturedAccessor(0);
replacedertNull(accessor.getSessionId());
replacedertNull(accessor.getSubscriptionId());
replacedertEquals("/user/" + user.getName() + "/dest1", accessor.getDestination());
accessor = getCapturedAccessor(1);
replacedertNull(accessor.getSessionId());
replacedertNull(accessor.getSubscriptionId());
replacedertEquals("/user/" + user.getName() + "/dest2", accessor.getDestination());
}
19
View Source File : SendToMethodReturnValueHandlerTests.java
License : Apache License 2.0
Project Creator : langtianya
License : Apache License 2.0
Project Creator : langtianya
@Test
public void sendToDefaultDestinationWhenUsingDotPathSeparator() throws Exception {
given(this.messageChannel.send(any(Message.clreplaced))).willReturn(true);
Message<?> inputMessage = createInputMessage("sess1", "sub1", "/app/", "dest.foo.bar", null);
this.handler.handleReturnValue(PAYLOAD, this.sendToDefaultDestReturnType, inputMessage);
verify(this.messageChannel, times(1)).send(this.messageCaptor.capture());
SimpMessageHeaderAccessor accessor = getCapturedAccessor(0);
replacedertEquals("/topic/dest.foo.bar", accessor.getDestination());
}
19
View Source File : WebSocketConfig.java
License : GNU General Public License v2.0
Project Creator : LandvibeDev
License : GNU General Public License v2.0
Project Creator : LandvibeDev
@EventListener
public void onSocketDisconnected(SessionDisconnectEvent event) {
SimpMessageHeaderAccessor headerAccessor = SimpMessageHeaderAccessor.wrap(event.getMessage());
codeManager.handleDisconnection(headerAccessor);
}
19
View Source File : PlayQueueWSController.java
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
@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());
}
19
View Source File : PlayQueueWSController.java
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
@MessageMapping("/play/saved")
public void loadSavedPlayQueue(@DestinationVariable int playerId, SimpMessageHeaderAccessor headers) throws Exception {
Player player = getPlayer(playerId, headers);
playQueueService.loadSavedPlayQueue(player, headers.getSessionId());
}
19
View Source File : PlayQueueWSController.java
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
@MessageMapping("/play/shuffle")
public void playShuffle(@DestinationVariable int playerId, PlayQueueRequest req, SimpMessageHeaderAccessor headers) throws Exception {
Player player = getPlayer(playerId, headers);
playQueueService.playShuffle(player, req.getAlbumListType(), (int) req.getOffset(), req.getCount(), req.getGenre(), req.getDecade(), headers.getSessionId());
}
19
View Source File : PlayQueueWSController.java
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
@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());
}
19
View Source File : PlayQueueWSController.java
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
@MessageMapping("/reloadsearch")
public void reloadSearchCriteria(@DestinationVariable int playerId, SimpMessageHeaderAccessor headers) throws Exception {
Player player = getPlayer(playerId, headers);
playQueueService.reloadSearchCriteria(player, headers.getSessionId());
}
19
View Source File : PlayQueueWSController.java
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
@MessageMapping("/play/podcastepisode/newest")
public void playNewestPodcastEpisode(@DestinationVariable int playerId, PlayQueueRequest req, SimpMessageHeaderAccessor headers) throws Exception {
Player player = getPlayer(playerId, headers);
playQueueService.playNewestPodcastEpisode(player, req.getIndex(), headers.getSessionId());
}
19
View Source File : PlayQueueWSController.java
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
@MessageMapping("/jukebox/position")
public void setJukeboxPosition(@DestinationVariable int playerId, int positionInSeconds, SimpMessageHeaderAccessor headers) throws Exception {
Player player = getPlayer(playerId, headers);
playQueueService.setJukeboxPosition(player, positionInSeconds);
}
19
View Source File : PlayQueueWSController.java
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
@MessageMapping("/up")
public void up(@DestinationVariable int playerId, int index, SimpMessageHeaderAccessor headers) throws Exception {
Player player = getPlayer(playerId, headers);
playQueueService.up(player, index);
}
19
View Source File : PlayQueueWSController.java
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
@MessageMapping("/add")
public void add(@DestinationVariable int playerId, PlayQueueRequest req, SimpMessageHeaderAccessor headers) throws Exception {
Player player = getPlayer(playerId, headers);
playQueueService.add(player, req.getIds(), req.getIndex(), player.isWeb(), true);
}
19
View Source File : PlayQueueWSController.java
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
@MessageMapping("/play/random")
public void playRandom(@DestinationVariable int playerId, PlayQueueRequest req, SimpMessageHeaderAccessor headers) throws Exception {
Player player = getPlayer(playerId, headers);
playQueueService.playRandom(player, req.getId(), req.getCount(), headers.getSessionId());
}
19
View Source File : PlayQueueWSController.java
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
//
// Methods dedicated to jukebox
//
@MessageMapping("/jukebox/gain")
public void setJukeboxGain(@DestinationVariable int playerId, float gain, SimpMessageHeaderAccessor headers) throws Exception {
Player player = getPlayer(playerId, headers);
playQueueService.setJukeboxGain(player, gain);
}
19
View Source File : PlayQueueWSController.java
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
@MessageMapping("/shuffle")
public void shuffle(@DestinationVariable int playerId, SimpMessageHeaderAccessor headers) throws Exception {
Player player = getPlayer(playerId, headers);
playQueueService.shuffle(player);
}
19
View Source File : PlayQueueWSController.java
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
@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());
}
19
View Source File : PlayQueueWSController.java
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
@MessageMapping("/skip")
public void skip(@DestinationVariable int playerId, PlayQueueRequest req, SimpMessageHeaderAccessor headers) throws Exception {
Player player = getPlayer(playerId, headers);
playQueueService.skip(player, req.getIndex(), req.getOffset());
}
19
View Source File : PlayQueueWSController.java
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
@MessageMapping("/remove")
public void remove(@DestinationVariable int playerId, List<Integer> indices, SimpMessageHeaderAccessor headers) throws Exception {
Player player = getPlayer(playerId, headers);
playQueueService.remove(player, indices);
}
19
View Source File : PlayQueueWSController.java
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
@MessageMapping("/toggleStartStop")
public void toggleStartStop(@DestinationVariable int playerId, SimpMessageHeaderAccessor headers) throws Exception {
Player player = getPlayer(playerId, headers);
playQueueService.toggleStartStop(player);
}
19
View Source File : PlayQueueWSController.java
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
@MessageMapping("/add/playlist")
public void addPlaylist(@DestinationVariable int playerId, PlayQueueRequest req, SimpMessageHeaderAccessor headers) throws Exception {
Player player = getPlayer(playerId, headers);
playQueueService.addPlaylist(player, req.getId(), player.isWeb());
}
19
View Source File : PlayQueueWSController.java
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
@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());
}
19
View Source File : PlayQueueWSController.java
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
//
// End : Methods dedicated to jukebox
//
private Player getPlayer(int playerId, SimpMessageHeaderAccessor headers) throws Exception {
return playerService.getPlayer((HttpServletRequest) headers.getSessionAttributes().get(WebsocketConfiguration.UNDERLYING_SERVLET_REQUEST), null, playerId, true, false);
}
19
View Source File : PlayQueueWSController.java
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
License : GNU General Public License v3.0
Project Creator : airsonic-advanced
@MessageMapping("/play/similar")
public void playSimilar(@DestinationVariable int playerId, PlayQueueRequest req, SimpMessageHeaderAccessor headers) throws Exception {
Player player = getPlayer(playerId, headers);
playQueueService.playSimilar(player, req.getId(), req.getCount(), headers.getSessionId());
}
See More Examples