瀏覽代碼

Swap /topic into /direct

Greg Turnquist 10 年之前
父節點
當前提交
f450d6b8fa

+ 1 - 1
complete/src/main/java/hello/GreetingController.java

@@ -9,7 +9,7 @@ public class GreetingController {
 
 
 
 
     @MessageMapping("/hello")
     @MessageMapping("/hello")
-    @SendTo("/topic/greetings")
+    @SendTo("/direct/greetings")
     public Greeting greeting(HelloMessage message) throws Exception {
     public Greeting greeting(HelloMessage message) throws Exception {
         Thread.sleep(3000); // simulated delay
         Thread.sleep(3000); // simulated delay
         return new Greeting("Hello, " + message.getName() + "!");
         return new Greeting("Hello, " + message.getName() + "!");

+ 1 - 1
complete/src/main/java/hello/WebSocketConfig.java

@@ -12,7 +12,7 @@ public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
 
 
 	@Override
 	@Override
 	public void configureMessageBroker(MessageBrokerRegistry config) {
 	public void configureMessageBroker(MessageBrokerRegistry config) {
-		config.enableSimpleBroker("/topic");
+		config.enableSimpleBroker("/direct");
 		config.setApplicationDestinationPrefixes("/app");
 		config.setApplicationDestinationPrefixes("/app");
 	}
 	}
 
 

+ 1 - 1
complete/src/main/resources/static/index.html

@@ -20,7 +20,7 @@
             stompClient.connect({}, function(frame) {
             stompClient.connect({}, function(frame) {
                 setConnected(true);
                 setConnected(true);
                 console.log('Connected: ' + frame);
                 console.log('Connected: ' + frame);
-                stompClient.subscribe('/topic/greetings', function(greeting){
+                stompClient.subscribe('/direct/greetings', function(greeting){
                     showGreeting(JSON.parse(greeting.body).content);
                     showGreeting(JSON.parse(greeting.body).content);
                 });
                 });
             });
             });