контроллер:
Код: Выделить всё
@Controller
@MessageMapping("/api/v1")
public class LeaderboardController {
@MessageMapping("/leaderboard/{lb}")
public void changes(@Payload ScoreDto request,
@DestinationVariable String lb,
Principal principal){
System.out.println("Received: " + request);
}
}
Код: Выделить всё
CONNECT
accept-version:1.2
host:localhost
SUBSCRIBE
id:sub-0
destination:/topic/update/racers
SEND
destination:/api/v1/leaderboard/racers
content-type:application/json
{"name":"alex","score":42}
Код: Выделить всё
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/web-socket/connect")
.setAllowedOriginPatterns("*");
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... -connectio