package org.araymond.joal.web.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;

/**
 * Created by raymo on 22/06/2017.
 */
@ConditionalOnProperty(name = "spring.main.web-environment", havingValue = "true")
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {

    private final String webSocketPathPrefix;

    public WebSocketConfig(@Value("${joal.ui.path.prefix}")final String webSocketPathPrefix) {
        this.webSocketPathPrefix = webSocketPathPrefix;
    }

    @Override
    public void configureMessageBroker(final MessageBrokerRegistry config) {
        config.enableSimpleBroker(
                "/global",
                "/announce",
                "/config",
                "/torrents"
        );
        config.setApplicationDestinationPrefixes("/joal");
    }

    @Override
    public void registerStompEndpoints(final StompEndpointRegistry registry) {
        registry.addEndpoint(this.webSocketPathPrefix)
                .setAllowedOrigins("*");
    }

}

@@ -565,16 +565,104 @@
 egistry;
+%0Aimport org.springframework.web.socket.config.annotation.WebSocketTransportRegistration;
 %0A%0A/**%0A *
@@ -1104,32 +1104,347 @@
 hPrefix;%0A    %7D%0A%0A
+    @Override%0A    public void configureWebSocketTransport(final WebSocketTransportRegistration registration) %7B%0A        registration%0A                .setMessageSizeLimit(1000 * 1024) // Max outgoing message size =%3E 1Mo%0A                .setSendBufferSizeLimit(5000 * 1024); // Max incoming message size =%3E 5Mo%0A    %7D%0A%0A
     @Override%0A  

Increase WebSocket maximum message size