package com.vetti.socket;

import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean;

import javax.websocket.server.ServerEndpointConfig;

@Component
public class LargeMessageWebSocketConfigurator extends ServerEndpointConfig.Configurator {

    @Bean
    public ServletServerContainerFactoryBean createWebSocketContainer() {
        ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean();
        container.setMaxTextMessageBufferSize(1048576); // 文本消息缓冲区
        container.setMaxBinaryMessageBufferSize(10485760); // 二进制消息缓冲区
        return container;
    }
}
