Reputation: 4145
I have a Spring Boot/Angular 17 application using StompJS. I am NOT using rx-stomp.
This is my controller on the backend:
@RestController
@MessageMapping("idle")
public class IdleWebsocketController {
private AppUserService userService;
public IdleWebsocketController(AppUserService userService) {
super();
this.userService = userService;
}
@MessageMapping("resetTimer")
@SendToUser("/topic/resetTimer")
Long sendResetIdle(Principal principal) {
String userId = principal.getName();
userService.updateActivity(userId);
Long time = new Date().getTime();
return time;
}
}
On the UI side, I can publish to /idle/resetTimer. I try to subscribe to the resetTimer topic with this code:
const callback : messageCallbackType = (message) => {
console.log(`Message: ${JSON.stringify(message)}`);
};
return of(undefined)
.pipe(
tap(() => {
this.websocketService.subscribe("/user/topic/resetTimer", callback);
}),
);
(The of(undefined)
is because I need to run the several functions together in a combineLatest
call elsewhere, so I need to return an Observable<void>
).
I don't see any errors suscribing, but I am getting no results back to the UI side once the timer is updated on the API side.
Am I subscribed incorrectly?
Upvotes: 0
Views: 38