fixed web-socket and add rewards on post

This commit is contained in:
SlimusMinus
2026-08-12 00:41:31 +03:00
parent f3ba7e6512
commit 13ed934c60
12 changed files with 107 additions and 52 deletions

View File

@@ -1,8 +1,9 @@
package com.krylov.refound.config;
import com.krylov.refound.util.WsHandshakeInterceptor;
import com.krylov.refound.util.WsStompInterceptor;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.ChannelRegistration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
@@ -13,19 +14,23 @@ import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerCo
@RequiredArgsConstructor
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
private final WsHandshakeInterceptor wsHandshakeInterceptor;
private final WsStompInterceptor wsStompInterceptor;
@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
registry.enableSimpleBroker("/topic"); // сервер → клиент
registry.setApplicationDestinationPrefixes("/app"); // клиент → сервер
registry.enableSimpleBroker("/topic");
registry.setApplicationDestinationPrefixes("/app");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/ws")
.setAllowedOriginPatterns("*")
.addInterceptors(wsHandshakeInterceptor)
.withSockJS();
}
@Override
public void configureClientInboundChannel(ChannelRegistration registration) {
registration.interceptors(wsStompInterceptor);
}
}