package org.framework.lazy.cloud.network.heartbeat.server.config;


import org.framework.lazy.cloud.network.heartbeat.common.adapter.ChannelFlowAdapter;
import org.framework.lazy.cloud.network.heartbeat.server.netty.advanced.*;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.*;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Role;


@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public class HeartbeatServerConfiguration {

    /**
     * 服务端 处理客户端心跳
     *
     * @return ServerHandleChannelHeartbeatTypeAdvanced
     */
    @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
    @Bean
    public ServerHandleChannelHeartbeatTypeAdvanced serverChannelHeartbeatTypeAdvanced() {
        return new ServerHandleChannelHeartbeatTypeAdvanced();
    }

    /**
     * 处理 服务端处理客户端数据传输
     *
     * @return ServerHandleReportServicePermeateClientTransferTypeAdvanced
     */
    @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
    @Bean
    public ServerHandleReportServicePermeateClientTransferTypeAdvanced serverReportChannelTransferTypeAdvanced(ChannelFlowAdapter channelFlowAdapter) {
        return new ServerHandleReportServicePermeateClientTransferTypeAdvanced(channelFlowAdapter);
    }

    @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
    @Bean
    public ServerHandleClientConnectSuccessTypeAdvanced serverReportConnectSuccessTypeAdvanced(
            LazyClientStatsChangeApplication lazyClientStatsChangeApplication,
            LazyNettyClientBlacklistApplication lazyNettyClientBlacklistApplication,
            LazyInternalNetworkServerPermeateClientMappingApplication lazyInternalNetworkServerPermeateClientMappingApplication,
            LazyInternalNetworkClientPermeateServerMappingApplication lazyInternalNetworkClientPermeateServerMappingApplication,
            LazyInternalNetworkClientPermeateClientMappingApplication lazyInternalNetworkClientPermeateClientMappingApplication) {
        return new ServerHandleClientConnectSuccessTypeAdvanced(lazyClientStatsChangeApplication,
                lazyNettyClientBlacklistApplication,
                lazyInternalNetworkServerPermeateClientMappingApplication,
                lazyInternalNetworkClientPermeateServerMappingApplication,
                lazyInternalNetworkClientPermeateClientMappingApplication);
    }

    /**
     * 服务端处理集群注册信息
     *
     * @param lazyNettyClusterNodeApplication 集群信息获取
     * @return ServerHandleReportClusterNodeRegisterTypeAdvanced
     */
    @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
    @Bean
    public ServerHandleReportClusterNodeRegisterTypeAdvanced serverHandleReportClusterNodeRegisterTypeAdvanced() {
        return new ServerHandleReportClusterNodeRegisterTypeAdvanced();
    }

    @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
    @Bean
    public ServerHandleReportDisconnectTypeAdvanced serverReportDisconnectTypeAdvanced(LazyClientStatsChangeApplication lazyClientStatsChangeApplication) {
        return new ServerHandleReportDisconnectTypeAdvanced(lazyClientStatsChangeApplication);
    }

    @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
    @Bean
    public ServerHandleReportServicePermeateClientCloseVisitorTypeAdvanced serverReportSingleClientCloseVisitorTypeAdvanced() {
        return new ServerHandleReportServicePermeateClientCloseVisitorTypeAdvanced();
    }

    @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
    @Bean
    public ServerHandleReportServicePermeateClientRealConnectTypeAdvanced serverReportSingleClientRealConnectTypeAdvanced() {
        return new ServerHandleReportServicePermeateClientRealConnectTypeAdvanced();
    }

    @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
    @Bean
    public ServerHandleReportStagingClosedTypeAdvanced serverReportStagingClosedTypeAdvanced(LazyClientStatsChangeApplication lazyClientStatsChangeApplication) {
        return new ServerHandleReportStagingClosedTypeAdvanced(lazyClientStatsChangeApplication);
    }

    @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
    @Bean
    public ServerHandleReportStagingOpenedTypeAdvanced serverReportStagingOpenedTypeAdvanced(LazyClientStatsChangeApplication lazyClientStatsChangeApplication) {
        return new ServerHandleReportStagingOpenedTypeAdvanced(lazyClientStatsChangeApplication);
    }


}
