I am creating a simple client-server demo using websockets. In this demo client you can subscribe to various topics. Whenever the server has something to send, it will simply send a message on the relevant topic, and only signed clients will receive the same message.
My server should receive confirmation when sending a message on any topic, but I'm a little confused how to get this confirmation of a sent message when the sending method returns void
below is my WebSocketConfig class ,
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableSimpleBroker("/testApp");
config.setApplicationDestinationPrefixes("/app");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/message").withSockJS();
}
}
The following shows how a subscription to a topic occurs on the client side.
var topic = '/testApp/testTopic';
stompClient.subscribe(topic, function(greeting){
});
, ,
String message = "test message";
this.template.convertAndSend(topic, new Chat(message));
(.. this.template.convertAndSend(topic, new Chat(message));) void
/ , , , ?