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


import org.framework.lazy.cloud.network.heartbeat.client.netty.advanced.*;
import org.framework.lazy.cloud.network.heartbeat.client.netty.event.ClientChangeEvent;
import org.framework.lazy.cloud.network.heartbeat.common.advanced.HandleChannelTypeAdvanced;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Role;

import java.util.List;

@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@ConditionalOnProperty(prefix = NettyClientProperties.PREFIX, name = "enabled", havingValue = "true", matchIfMissing = true)
public class HeartbeatClientConfiguration {

    /**
     * 服务端 处理客户端心跳
     *
     * @return ClientHandleChannelHeartbeatTypeAdvanced
     */
    @Bean
    public ClientHandleChannelHeartbeatTypeAdvanced clientChannelHeartbeatTypeAdvanced() {
        return new ClientHandleChannelHeartbeatTypeAdvanced();
    }

    /**
     * 处理 客户端代理的真实端口自动读写
     *
     * @return ClientHandleDistributeSingleClientRealAutoReadConnectTypeAdvanced
     */
    @Bean
    public ClientHandleDistributeSingleClientRealAutoReadConnectTypeAdvanced handleDistributeSingleClientRealAutoReadConnectTypeAdvanced() {
        return new ClientHandleDistributeSingleClientRealAutoReadConnectTypeAdvanced();
    }

    /**
     * 处理 接收服务端发送过来的聊天信息
     *
     * @return ClientHandleDistributeSingleClientMessageTypeAdvanced
     */
    @Bean
    public ClientHandleDistributeSingleClientMessageTypeAdvanced handleDistributeSingleClientMessageTypeAdvanced() {
        return new ClientHandleDistributeSingleClientMessageTypeAdvanced();
    }
    /**
     * 处理 客户端渗透服务端数据传输通道连接成功
     *
     * @return ClientHandleDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced
     */
    @Bean
    public ClientHandleDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced clientHandleDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced() {
        return new ClientHandleDistributeClientTransferServerPermeateChannelConnectionSuccessfulTypeAdvanced();
    }

    /**
     * 处理 客户端渗透客户端数据传输通道连接成功
     *
     * @return ClientHandleDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced
     */
    @Bean
    public ClientHandleDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced clientHandleDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced() {
        return new ClientHandleDistributeClientTransferClientPermeateChannelConnectionSuccessfulTypeAdvanced();
    }

    @Bean
    public ClientHandleDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced clientHandleDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced() {
        return new ClientHandleDistributeClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced();
    }

    @Bean
    public ClientHandleDistributeClientTransferClientRequestTypeAdvanced clientHandleDistributeClientTransferClientTypeAdvanced() {
        return new ClientHandleDistributeClientTransferClientRequestTypeAdvanced();
    }

    @Bean
    public ClientHandleDistributeServicePermeateClientTransferClientResponseTypeAdvanced clientHandleDistributeClientTransferClientResponseTypeAdvanced() {
        return new ClientHandleDistributeServicePermeateClientTransferClientResponseTypeAdvanced();
    }
    @Bean
    public ClientHandleDistributeSingleClientRealCloseVisitorTypeAdvanced handleDistributeSingleClientRealCloseVisitorTypeAdvanced() {
        return new ClientHandleDistributeSingleClientRealCloseVisitorTypeAdvanced();
    }

    @Bean
    public ClientHandleChannelTransferTypeAdvancedHandleDistributeDistribute handleChannelTransferTypeAdvancedHandleDistribute(NettyClientProperties nettyClientProperties) {
        return new ClientHandleChannelTransferTypeAdvancedHandleDistributeDistribute(nettyClientProperties);
    }

    @Bean
    public HandleDistributeConnectSuccessNotificationTypeAdvancedHandle handleDistributeConnectSuccessNotificationTypeAdvancedHandle(ClientChangeEvent clientChangeEvent) {
        return new HandleDistributeConnectSuccessNotificationTypeAdvancedHandle(clientChangeEvent);
    }

    @Bean
    public HandleClientChannelActiveAdvanced handleClientChannelActiveAdvanced(NettyClientProperties nettyClientProperties) {
        return new HandleClientChannelActiveAdvanced(nettyClientProperties);
    }

    @Bean
    public HandleDistributeDisconnectTypeAdvancedHandle handleDistributeDisconnectTypeAdvancedHandle(ClientChangeEvent clientChangeEvent) {
        return new HandleDistributeDisconnectTypeAdvancedHandle(clientChangeEvent);
    }

    @Bean
    public HandleDistributeStagingClosedTypeAdvanced handleDistributeStagingClosedTypeAdvanced() {
        return new HandleDistributeStagingClosedTypeAdvanced();
    }

    @Bean
    public HandleDistributeStagingOpenedTypeAdvanced handleDistributeStagingOpenedTypeAdvanced() {
        return new HandleDistributeStagingOpenedTypeAdvanced();
    }

    /**
     * 处理 客户端渗透服务端init信息
     *
     * @return ClientHandleDistributeClientPermeateServerInitTypeAdvanced
     */
    @Bean
    public ClientHandleDistributeClientPermeateServerInitTypeAdvanced clientHandleDistributeClientPermeateServerInitTypeAdvanced(NettyClientProperties nettyClientProperties) {
        return new ClientHandleDistributeClientPermeateServerInitTypeAdvanced(nettyClientProperties);
    }
    /**
     * 处理 客户端渗透服务端init close 信息
     *
     * @return ClientHandleDistributeClientPermeateServerCloseTypeAdvanced
     */
    @Bean
    public ClientHandleDistributeClientPermeateServerCloseTypeAdvanced clientHandleDistributeClientPermeateServerCloseTypeAdvanced( ) {
        return new ClientHandleDistributeClientPermeateServerCloseTypeAdvanced();
    }
    @Bean
    public ClientHandleDistributeClientPermeateServerTransferTypeAdvanced clientHandleDistributeClientPermeateServerTransferTypeAdvanced( ) {
        return new ClientHandleDistributeClientPermeateServerTransferTypeAdvanced();
    }

    @Bean
    public ClientHandleDistributeClientPermeateClientCloseTypeAdvanced clientHandleDistributeClientPermeateClientCloseTypeAdvanced() {
        return new ClientHandleDistributeClientPermeateClientCloseTypeAdvanced();
    }

    @Bean
    public ClientHandleDistributeClientPermeateClientInitTypeAdvanced clientHandleDistributeClientPermeateClientInitTypeAdvanced() {
        return new ClientHandleDistributeClientPermeateClientInitTypeAdvanced();
    }

    @Bean
    public ClientHandleDistributeClientPermeateClientTransferCloseTypeAdvanced clientHandleDistributeClientPermeateClientTransferCloseTypeAdvanced() {
        return new ClientHandleDistributeClientPermeateClientTransferCloseTypeAdvanced();
    }


    @Bean
    public ClientHandleDistributeServicePermeateClientRealConnectTypeAdvanced clientHandleDistributeSingleClientRealConnectTypeAdvanced(NettyClientProperties nettyClientProperties,
                                                                                                                                        List<HandleChannelTypeAdvanced> handleChannelTypeAdvancedList) {
        return new ClientHandleDistributeServicePermeateClientRealConnectTypeAdvanced(nettyClientProperties, handleChannelTypeAdvancedList);
    }

    @Bean
    public ClientHandleHandleDistributeClientPermeateServerTransferCloseTypeAdvanced clientHandleHandleDistributeClientPermeateServerTransferCloseTypeAdvanced() {
        return new ClientHandleHandleDistributeClientPermeateServerTransferCloseTypeAdvanced();
    }
}
