use of org.springframework.messaging.simp.SimpMessageType in project spring-framework by spring-projects.
the class AbstractSubscriptionRegistry method findSubscriptions.
@Override
public final MultiValueMap<String, String> findSubscriptions(Message<?> message) {
MessageHeaders headers = message.getHeaders();
SimpMessageType type = SimpMessageHeaderAccessor.getMessageType(headers);
if (!SimpMessageType.MESSAGE.equals(type)) {
throw new IllegalArgumentException("Unexpected message type: " + type);
}
String destination = SimpMessageHeaderAccessor.getDestination(headers);
if (destination == null) {
if (logger.isErrorEnabled()) {
logger.error("No destination in " + message);
}
return EMPTY_MAP;
}
return findSubscriptionsInternal(destination, message);
}
use of org.springframework.messaging.simp.SimpMessageType in project spring-framework by spring-projects.
the class AbstractSubscriptionRegistry method unregisterSubscription.
@Override
public final void unregisterSubscription(Message<?> message) {
MessageHeaders headers = message.getHeaders();
SimpMessageType messageType = SimpMessageHeaderAccessor.getMessageType(headers);
if (!SimpMessageType.UNSUBSCRIBE.equals(messageType)) {
throw new IllegalArgumentException("Expected UNSUBSCRIBE: " + message);
}
String sessionId = SimpMessageHeaderAccessor.getSessionId(headers);
if (sessionId == null) {
if (logger.isErrorEnabled()) {
logger.error("No sessionId in " + message);
}
return;
}
String subscriptionId = SimpMessageHeaderAccessor.getSubscriptionId(headers);
if (subscriptionId == null) {
if (logger.isErrorEnabled()) {
logger.error("No subscriptionId " + message);
}
return;
}
removeSubscriptionInternal(sessionId, subscriptionId, message);
}
use of org.springframework.messaging.simp.SimpMessageType in project spring-framework by spring-projects.
the class StompCommandTests method getMessageType.
@Test
public void getMessageType() throws Exception {
for (StompCommand stompCommand : StompCommand.values()) {
SimpMessageType simp = messageTypes.get(stompCommand);
if (simp == null) {
simp = SimpMessageType.OTHER;
}
assertSame(simp, stompCommand.getMessageType());
}
}
use of org.springframework.messaging.simp.SimpMessageType in project spring-security by spring-projects.
the class SimpMessageTypeMatcher method matches.
public boolean matches(Message<? extends Object> message) {
MessageHeaders headers = message.getHeaders();
SimpMessageType messageType = SimpMessageHeaderAccessor.getMessageType(headers);
return typeToMatch == messageType;
}
use of org.springframework.messaging.simp.SimpMessageType in project spring-security by spring-projects.
the class MessageSecurityMetadataSourceRegistry method simpTypeMatchers.
/**
* Maps a {@link List} of {@link SimpDestinationMessageMatcher} instances.
*
* @param typesToMatch the {@link SimpMessageType} instance to match on
* @return the {@link Constraint} associated to the matchers.
*/
public Constraint simpTypeMatchers(SimpMessageType... typesToMatch) {
MessageMatcher<?>[] typeMatchers = new MessageMatcher<?>[typesToMatch.length];
for (int i = 0; i < typesToMatch.length; i++) {
SimpMessageType typeToMatch = typesToMatch[i];
typeMatchers[i] = new SimpMessageTypeMatcher(typeToMatch);
}
return matchers(typeMatchers);
}
Aggregations