Java Code Examples for org.springframework.messaging.simp.config.MessageBrokerRegistry#setUserDestinationPrefix()

The following examples show how to use org.springframework.messaging.simp.config.MessageBrokerRegistry#setUserDestinationPrefix() . 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: DefaultWebSocketBrokerConfig.java    From spring-boot-starter-samples with Apache License 2.0 6 votes vote down vote up
/** 
 * 配置了一个简单的消息代理,如果不重载,默认情况下回自动配置一个简单的内存消息代理,用来处理以"/topic"为前缀的消息。这里重载configureMessageBroker()方法,  消息代理将会处理前缀为"/topic"和"/queue"的消息。 
 * @param registry 
 */  
@Override  
public void configureMessageBroker(MessageBrokerRegistry registry) {  
    
	//应用程序以/app为前缀,代理目的地以/topic 为前缀  
	registry.enableSimpleBroker("/topic");  
	
    registry.setApplicationDestinationPrefixes("/app");  
    registry.setUserDestinationPrefix("/user");
    
    /*
    registry.enableSimpleBroker("/topic", "/user");这句话表示在topic和user这两个域上可以向客户端发消息。
    registry.setUserDestinationPrefix("/user");这句话表示给指定用户发送一对一的主题前缀是"/user"。
    registry.setApplicationDestinationPrefixes("/app");这句话表示客户单向服务器端发送时的主题上面需要加"/app"作为前缀。
    stompEndpointRegistry.addEndpoint("/hello").setAllowedOrigins("*").withSokJS();这个和客户端创建连接时的url有关,其中setAllowedOrigins()方法表示允许连接的域名,withSockJS()方法表示支持以SockJS方式连接服务器。
    */
}
 
Example 2
Source File: WebSocketConfig.java    From WebSocketExample with MIT License 5 votes vote down vote up
/**
 * Configure message broker
 * <p>
 * 配置使用消息代理
 *
 * @param registry message broker registry
 */
@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
    // Configure global message broker, client will subscribe these message brokers to receive messages
    // 统一配置消息代理,消息代理即订阅点,客户端通过订阅消息代理点接受消息
    registry.enableSimpleBroker("/b", "/g", "/user");

    // configure point to point message's prefix
    // 配置点对点消息的前缀
    registry.setUserDestinationPrefix("/user");
}
 
Example 3
Source File: WebSocketConfig.java    From ZTuoExchange_framework with MIT License 4 votes vote down vote up
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
    config.enableSimpleBroker("/topic","/user");
    config.setUserDestinationPrefix("/user/");
    config.setApplicationDestinationPrefixes("/app");
}
 
Example 4
Source File: WebSocketConfig.java    From ZTuoExchange_framework with MIT License 4 votes vote down vote up
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
    config.enableSimpleBroker("/topic","/user");
    config.setUserDestinationPrefix("/user/");
    config.setApplicationDestinationPrefixes("/app");
}
 
Example 5
Source File: WebsocketConfig.java    From spring-boot-protocol with Apache License 2.0 4 votes vote down vote up
@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
    registry.enableSimpleBroker("/topic/");//定义了一个客户端订阅地址的前缀信息,也就是客户端接收服务端发送消息的前缀信息
    registry.setApplicationDestinationPrefixes("/app");//api全局的前缀名
    registry.setUserDestinationPrefix("/user/");// 点对点使用的订阅前缀(客户端订阅路径上会体现出来),不设置的话,默认也是/user/ , 如果设置了全局前缀效果为 /app/user/xxx
}
 
Example 6
Source File: WebSocketConfig.java    From JavaQuarkBBS with Apache License 2.0 4 votes vote down vote up
@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
    registry.enableSimpleBroker("/topic","/user");//可以在topic,user域向客户端发送消息
    registry.setUserDestinationPrefix("/user/");//指定用户发送(一对一)的主题前缀是“/user/”
    registry.setApplicationDestinationPrefixes("/app");//客户端向服务端发送时的主题上面需要加"/app"作为前缀;
}
 
Example 7
Source File: SocketBrokerConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
    config.enableSimpleBroker(SECURED_CHAT_HISTORY, SECURED_CHAT_SPECIFIC_USER);
    config.setApplicationDestinationPrefixes("/spring-security-mvc-socket");
    config.setUserDestinationPrefix("/secured/user");
}