package com.cn;

import com.cn.config.PropertyDataBaseConfigBuilder;
import com.cn.model.ServiceAccountRoleDepartmentMiddle;
import com.cn.processor.IMChatWsHandshakeProcessor;
import com.cn.service.IMChatLoginServiceProcessor;
import org.apache.commons.lang3.StringUtils;
import org.jim.common.ImConfig;
import org.jim.common.ImConst;
import org.jim.common.cache.redis.JedisTemplate;
import org.jim.common.config.PropertyImConfigBuilder;
import org.jim.common.packets.Command;
import org.jim.common.utils.PropUtil;
import org.jim.server.ImServerStarter;
import org.jim.server.command.CommandManager;
import org.jim.server.command.handler.HandshakeReqHandler;
import org.jim.server.command.handler.LoginReqHandler;
import org.jim.server.enums.VisitTypeEnum;
import org.tio.core.ssl.SslConfig;

import java.sql.SQLOutput;
import java.util.List;

/**
 * @author Darren
 * @date 2020/1/30 16:25
 */
public class ServerChatStart {

    /**
     * 项目入口
     * @param args
     * @return {@link }
     * @author Darren
     * @date 2020/1/30 16:28
     */
    public static void main(String[] args) throws Exception {
        //加载数据库配置
        PropertyDataBaseConfigBuilder.init("application.properties");
        //加载imcomfig
        ImConfig imConfig = new PropertyImConfigBuilder("jim.properties").build();

        //设置群组监听器，非必须，根据需要自己选择性实现;
        //imConfig.setImGroupListener(new ImDemoGroupListener());

        ImServerStarter imServerStarter = new ImServerStarter(imConfig);
        /*****************start 以下处理器根据业务需要自行添加与扩展，每个Command都可以添加扩展,此处为demo中处理**********************************/

        HandshakeReqHandler handshakeReqHandler = CommandManager.getCommand(Command.COMMAND_HANDSHAKE_REQ, HandshakeReqHandler.class);
        //添加自定义握手处理器;
        handshakeReqHandler.addProcessor(new IMChatWsHandshakeProcessor());
        LoginReqHandler loginReqHandler = CommandManager.getCommand(Command.COMMAND_LOGIN_REQ,LoginReqHandler.class);
        //添加登录业务处理器;
        loginReqHandler.addProcessor(new IMChatLoginServiceProcessor());


        /*****************end *******************************************************************************************/

        imServerStarter.start();

    }


}
