Allison Ziegler 6 years ago
parent
commit
2b5e6f1f2f

+ 1
- 2
src/main/java/com/ziplinegreen/vault/Config/WebSocketConfig.java View File

15
 
15
 
16
     @Override
16
     @Override
17
     public void configureMessageBroker(MessageBrokerRegistry config) {
17
     public void configureMessageBroker(MessageBrokerRegistry config) {
18
-        config.enableSimpleBroker("/topic"); //marks
18
+        config.enableSimpleBroker("/topic");
19
         config.setApplicationDestinationPrefixes("/app"); //where the frontend sends things
19
         config.setApplicationDestinationPrefixes("/app"); //where the frontend sends things
20
     }
20
     }
21
 
21
 
22
     @Override
22
     @Override
23
     public void registerStompEndpoints(StompEndpointRegistry registry) {
23
     public void registerStompEndpoints(StompEndpointRegistry registry) {
24
-        //registry.addEndpoint("/posts");
25
         registry.addEndpoint("/vault-socket").withSockJS();
24
         registry.addEndpoint("/vault-socket").withSockJS();
26
     }
25
     }
27
 }
26
 }

+ 0
- 1
src/main/java/com/ziplinegreen/vault/Controller/PostController.java View File

46
 //    }
46
 //    }
47
 
47
 
48
     @MessageMapping("/posts/{userId}")
48
     @MessageMapping("/posts/{userId}")
49
-    //@MessageMapping("/posts")
50
     @SendTo("/topic/posts")
49
     @SendTo("/topic/posts")
51
     public Post createPost(@DestinationVariable("userId") Long userId, @RequestBody Post post) {
50
     public Post createPost(@DestinationVariable("userId") Long userId, @RequestBody Post post) {
52
     //public Post createPost(@RequestBody Post post) {
51
     //public Post createPost(@RequestBody Post post) {

+ 0
- 1
src/main/java/com/ziplinegreen/vault/Repository/PostRepository.java View File

11
 
11
 
12
 @RepositoryRestResource
12
 @RepositoryRestResource
13
 public interface PostRepository extends JpaRepository<Post,Long> {
13
 public interface PostRepository extends JpaRepository<Post,Long> {
14
-
15
     //@Query("select postcontent,timestamp from Post where user_id = :userId")
14
     //@Query("select postcontent,timestamp from Post where user_id = :userId")
16
     Iterable<Post> findByUserId(Long userId);
15
     Iterable<Post> findByUserId(Long userId);
17
 }
16
 }

+ 0
- 6
src/main/resources/static/app.js View File

20
         console.log('Connected: ' + frame);
20
         console.log('Connected: ' + frame);
21
         stompClient.subscribe('/topic/posts', function (greeting) {
21
         stompClient.subscribe('/topic/posts', function (greeting) {
22
             showGreeting(JSON.parse(greeting.body).message, JSON.parse(greeting.body).userName);
22
             showGreeting(JSON.parse(greeting.body).message, JSON.parse(greeting.body).userName);
23
-            //showGreeting()
24
         });
23
         });
25
     });
24
     });
26
 }
25
 }
49
     userPostUrl = "/app/posts/2";
48
     userPostUrl = "/app/posts/2";
50
 }
49
 }
51
 
50
 
52
-// function sendName() {
53
-//     stompClient.send("/app/posts/1", {}, JSON.stringify({'id': '','message': $("#message").val(),'userId': '1'}));
54
-// }
55
-
56
-
57
 
51
 
58
 function sendName() {
52
 function sendName() {
59
 
53